@@ -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        } , 
@@ -218,17 +218,20 @@ impl ExecutionContext {
218218                ref  file_type, 
219219                ref  has_header, 
220220            } )  => { 
221-                 let  file_format = match  file_type { 
222-                     FileType :: CSV  => { 
223-                         Ok ( Arc :: new ( CsvFormat :: default ( ) . with_has_header ( * has_header) ) 
224-                             as  Arc < dyn  FileFormat > ) 
225-                     } 
226-                     FileType :: Parquet  => { 
227-                         Ok ( Arc :: new ( ParquetFormat :: default ( ) )  as  Arc < dyn  FileFormat > ) 
228-                     } 
229-                     FileType :: Avro  => { 
230-                         Ok ( Arc :: new ( AvroFormat :: default ( ) )  as  Arc < dyn  FileFormat > ) 
231-                     } 
221+                 let  ( file_format,  file_extension)  = match  file_type { 
222+                     FileType :: CSV  => Ok ( ( 
223+                         Arc :: new ( CsvFormat :: default ( ) . with_has_header ( * has_header) ) 
224+                             as  Arc < dyn  FileFormat > , 
225+                         DEFAULT_CSV_EXTENSION , 
226+                     ) ) , 
227+                     FileType :: Parquet  => Ok ( ( 
228+                         Arc :: new ( ParquetFormat :: default ( ) )  as  Arc < dyn  FileFormat > , 
229+                         DEFAULT_PARQUET_EXTENSION , 
230+                     ) ) , 
231+                     FileType :: Avro  => Ok ( ( 
232+                         Arc :: new ( AvroFormat :: default ( ) )  as  Arc < dyn  FileFormat > , 
233+                         DEFAULT_AVRO_EXTENSION , 
234+                     ) ) , 
232235                    _ => Err ( DataFusionError :: NotImplemented ( format ! ( 
233236                        "Unsupported file type {:?}." , 
234237                        file_type
@@ -238,7 +241,7 @@ impl ExecutionContext {
238241                let  options = ListingOptions  { 
239242                    format :  file_format, 
240243                    collect_stat :  false , 
241-                     file_extension :  String :: new ( ) , 
244+                     file_extension :  file_extension . to_owned ( ) , 
242245                    target_partitions :  self 
243246                        . state 
244247                        . lock ( ) 
0 commit comments