@@ -40,7 +40,7 @@ use arrow::array::RecordBatch;
4040use arrow:: csv:: WriterBuilder ;
4141use arrow:: datatypes:: SchemaRef ;
4242use arrow:: datatypes:: { DataType , Field , Fields , Schema } ;
43- use datafusion_common:: config:: { ConfigOptions , CsvOptions } ;
43+ use datafusion_common:: config:: CsvOptions ;
4444use datafusion_common:: file_options:: csv_writer:: CsvWriterOptions ;
4545use datafusion_common:: { exec_err, not_impl_err, DataFusionError , FileType } ;
4646use datafusion_execution:: TaskContext ;
@@ -142,8 +142,8 @@ impl CsvFormat {
142142 }
143143
144144 /// True if the first line is a header.
145- pub fn has_header ( & self , config_opt : & ConfigOptions ) -> bool {
146- self . options . has_header ( config_opt )
145+ pub fn has_header ( & self ) -> Option < bool > {
146+ self . options . has_header
147147 }
148148
149149 /// The character separating values within a row.
@@ -245,7 +245,9 @@ impl FileFormat for CsvFormat {
245245 conf,
246246 // If format options does not specify whether there is a header,
247247 // we consult configuration options.
248- self . options . has_header ( state. config_options ( ) ) ,
248+ self . options
249+ . has_header
250+ . unwrap_or ( state. config_options ( ) . catalog . has_header ) ,
249251 self . options . delimiter ,
250252 self . options . quote ,
251253 self . options . escape ,
@@ -303,7 +305,10 @@ impl CsvFormat {
303305 while let Some ( chunk) = stream. next ( ) . await . transpose ( ) ? {
304306 let format = arrow:: csv:: reader:: Format :: default ( )
305307 . with_header (
306- self . options . has_header ( state. config_options ( ) ) && first_chunk,
308+ self . options
309+ . has_header
310+ . unwrap_or ( state. config_options ( ) . catalog . has_header )
311+ && first_chunk,
307312 )
308313 . with_delimiter ( self . options . delimiter ) ;
309314
0 commit comments