Skip to content

Commit

Permalink
fix clippy lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
tinfoil-knight committed Mar 22, 2024
1 parent 06500ef commit 2bb149e
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,33 +866,31 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
FileType::from_str(&file_type).map_err(|_| {
DataFusionError::Configuration(format!("Unknown FileType {}", file_type))
})?
} else if let Some(format) = options.remove("format") {
// try to infer file format from the "format" key in options
FileType::from_str(&format)
.map_err(|e| DataFusionError::Configuration(format!("{}", e)))?
} else {
if let Some(format) = options.remove("format") {
// try to infer file format from the "format" key in options
FileType::from_str(&format)
.map_err(|e| DataFusionError::Configuration(format!("{}", e)))?
} else {
let e = || {
DataFusionError::Configuration(
let e = || {
DataFusionError::Configuration(
"Format not explicitly set and unable to get file extension! Use STORED AS to define file format."
.to_string(),
)
};
// try to infer file format from file extension
let extension: &str = &Path::new(&statement.target)
.extension()
.ok_or_else(e)?
.to_str()
.ok_or_else(e)?
.to_lowercase();

FileType::from_str(extension).map_err(|e| {
DataFusionError::Configuration(format!(
"{}. Use STORED AS to define file format.",
e
))
})?
}
};
// try to infer file format from file extension
let extension: &str = &Path::new(&statement.target)
.extension()
.ok_or_else(e)?
.to_str()
.ok_or_else(e)?
.to_lowercase();

FileType::from_str(extension).map_err(|e| {
DataFusionError::Configuration(format!(
"{}. Use STORED AS to define file format.",
e
))
})?
};

let partition_by = statement
Expand Down

0 comments on commit 2bb149e

Please sign in to comment.