@@ -24,8 +24,8 @@ use crate::{
2424    datasource:: listing:: { ListingOptions ,  ListingTable } , 
2525    datasource:: { 
2626        file_format:: { 
27-             avro:: AvroFormat , 
28-             csv:: CsvFormat , 
27+             avro:: { AvroFormat ,   DEFAULT_AVRO_EXTENSION } , 
28+             csv:: { CsvFormat ,   DEFAULT_CSV_EXTENSION } , 
2929            parquet:: { ParquetFormat ,  DEFAULT_PARQUET_EXTENSION } , 
3030            FileFormat , 
3131        } , 
@@ -209,17 +209,20 @@ impl ExecutionContext {
209209                ref  file_type, 
210210                ref  has_header, 
211211            } )  => { 
212-                 let  file_format = match  file_type { 
213-                     FileType :: CSV  => { 
214-                         Ok ( Arc :: new ( CsvFormat :: default ( ) . with_has_header ( * has_header) ) 
215-                             as  Arc < dyn  FileFormat > ) 
216-                     } 
217-                     FileType :: Parquet  => { 
218-                         Ok ( Arc :: new ( ParquetFormat :: default ( ) )  as  Arc < dyn  FileFormat > ) 
219-                     } 
220-                     FileType :: Avro  => { 
221-                         Ok ( Arc :: new ( AvroFormat :: default ( ) )  as  Arc < dyn  FileFormat > ) 
222-                     } 
212+                 let  ( file_format,  file_extension)  = match  file_type { 
213+                     FileType :: CSV  => Ok ( ( 
214+                         Arc :: new ( CsvFormat :: default ( ) . with_has_header ( * has_header) ) 
215+                             as  Arc < dyn  FileFormat > , 
216+                         DEFAULT_CSV_EXTENSION , 
217+                     ) ) , 
218+                     FileType :: Parquet  => Ok ( ( 
219+                         Arc :: new ( ParquetFormat :: default ( ) )  as  Arc < dyn  FileFormat > , 
220+                         DEFAULT_PARQUET_EXTENSION , 
221+                     ) ) , 
222+                     FileType :: Avro  => Ok ( ( 
223+                         Arc :: new ( AvroFormat :: default ( ) )  as  Arc < dyn  FileFormat > , 
224+                         DEFAULT_AVRO_EXTENSION , 
225+                     ) ) , 
223226                    _ => Err ( DataFusionError :: NotImplemented ( format ! ( 
224227                        "Unsupported file type {:?}." , 
225228                        file_type
@@ -229,7 +232,7 @@ impl ExecutionContext {
229232                let  options = ListingOptions  { 
230233                    format :  file_format, 
231234                    collect_stat :  false , 
232-                     file_extension :  String :: new ( ) , 
235+                     file_extension :  file_extension . to_owned ( ) , 
233236                    target_partitions :  self 
234237                        . state 
235238                        . lock ( ) 
0 commit comments