@@ -58,6 +58,7 @@ pub struct CsvExec {
5858 delimiter : u8 ,
5959 quote : u8 ,
6060 escape : Option < u8 > ,
61+ comment : Option < u8 > ,
6162 /// Execution metrics
6263 metrics : ExecutionPlanMetricsSet ,
6364 /// Compression type of the file associated with CsvExec
@@ -73,6 +74,7 @@ impl CsvExec {
7374 delimiter : u8 ,
7475 quote : u8 ,
7576 escape : Option < u8 > ,
77+ comment : Option < u8 > ,
7678 file_compression_type : FileCompressionType ,
7779 ) -> Self {
7880 let ( projected_schema, projected_statistics, projected_output_ordering) =
@@ -92,6 +94,7 @@ impl CsvExec {
9294 metrics : ExecutionPlanMetricsSet :: new ( ) ,
9395 file_compression_type,
9496 cache,
97+ comment,
9598 }
9699 }
97100
@@ -113,6 +116,11 @@ impl CsvExec {
113116 self . quote
114117 }
115118
119+ /// Lines beginning with this byte are ignored.
120+ pub fn comment ( & self ) -> Option < u8 > {
121+ self . comment
122+ }
123+
116124 /// The escape character
117125 pub fn escape ( & self ) -> Option < u8 > {
118126 self . escape
@@ -234,6 +242,7 @@ impl ExecutionPlan for CsvExec {
234242 quote : self . quote ,
235243 escape : self . escape ,
236244 object_store,
245+ comment : self . comment ,
237246 } ) ;
238247
239248 let opener = CsvOpener {
@@ -265,9 +274,11 @@ pub struct CsvConfig {
265274 quote : u8 ,
266275 escape : Option < u8 > ,
267276 object_store : Arc < dyn ObjectStore > ,
277+ comment : Option < u8 > ,
268278}
269279
270280impl CsvConfig {
281+ #[ allow( clippy:: too_many_arguments) ]
271282 /// Returns a [`CsvConfig`]
272283 pub fn new (
273284 batch_size : usize ,
@@ -277,6 +288,7 @@ impl CsvConfig {
277288 delimiter : u8 ,
278289 quote : u8 ,
279290 object_store : Arc < dyn ObjectStore > ,
291+ comment : Option < u8 > ,
280292 ) -> Self {
281293 Self {
282294 batch_size,
@@ -287,6 +299,7 @@ impl CsvConfig {
287299 quote,
288300 escape : None ,
289301 object_store,
302+ comment,
290303 }
291304 }
292305}
@@ -309,6 +322,9 @@ impl CsvConfig {
309322 if let Some ( escape) = self . escape {
310323 builder = builder. with_escape ( escape)
311324 }
325+ if let Some ( comment) = self . comment {
326+ builder = builder. with_comment ( comment) ;
327+ }
312328
313329 builder
314330 }
@@ -570,6 +586,7 @@ mod tests {
570586 b',' ,
571587 b'"' ,
572588 None ,
589+ None ,
573590 file_compression_type. to_owned ( ) ,
574591 ) ;
575592 assert_eq ! ( 13 , csv. base_config. file_schema. fields( ) . len( ) ) ;
@@ -636,6 +653,7 @@ mod tests {
636653 b',' ,
637654 b'"' ,
638655 None ,
656+ None ,
639657 file_compression_type. to_owned ( ) ,
640658 ) ;
641659 assert_eq ! ( 13 , csv. base_config. file_schema. fields( ) . len( ) ) ;
@@ -702,6 +720,7 @@ mod tests {
702720 b',' ,
703721 b'"' ,
704722 None ,
723+ None ,
705724 file_compression_type. to_owned ( ) ,
706725 ) ;
707726 assert_eq ! ( 13 , csv. base_config. file_schema. fields( ) . len( ) ) ;
@@ -765,6 +784,7 @@ mod tests {
765784 b',' ,
766785 b'"' ,
767786 None ,
787+ None ,
768788 file_compression_type. to_owned ( ) ,
769789 ) ;
770790 assert_eq ! ( 14 , csv. base_config. file_schema. fields( ) . len( ) ) ;
@@ -827,6 +847,7 @@ mod tests {
827847 b',' ,
828848 b'"' ,
829849 None ,
850+ None ,
830851 file_compression_type. to_owned ( ) ,
831852 ) ;
832853 assert_eq ! ( 13 , csv. base_config. file_schema. fields( ) . len( ) ) ;
@@ -921,6 +942,7 @@ mod tests {
921942 b',' ,
922943 b'"' ,
923944 None ,
945+ None ,
924946 file_compression_type. to_owned ( ) ,
925947 ) ;
926948
0 commit comments