tinfoil-knight commented on code in PR #9744:
URL: https://github.com/apache/arrow-datafusion/pull/9744#discussion_r1536215729


##########
datafusion/sql/src/statement.rs:
##########
@@ -867,26 +867,32 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 DataFusionError::Configuration(format!("Unknown FileType {}", 
file_type))
             })?
         } else {
-            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
-                ))
-            })?
+            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 {

Review Comment:
   Note for Reviewer:
   I couldn't figure out a way to do an early return (while handling errors 
properly) from the if-block so had to move all this code. 
   
   Please let me know if you've any better suggestions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to