@@ -83,7 +83,7 @@ impl InputFormatCSV {
83
83
column_type : field. data_type . to_string ( ) ,
84
84
empty_field_as : empty_filed_as. to_string ( ) ,
85
85
remedy : format ! (
86
- "one of the following options: 1. Modify the `{}` column to allow NULL values. 2. Set ` EMPTY_FIELD_AS = FIELD_DEFAULT` ." ,
86
+ "one of the following options: 1. Modify the `{}` column to allow NULL values. 2. Set EMPTY_FIELD_AS to FIELD_DEFAULT." ,
87
87
field. name( )
88
88
) ,
89
89
} ) ;
@@ -394,14 +394,18 @@ impl AligningStateTextBased for CsvReaderState {
394
394
let size_in = buf_in. len ( ) ;
395
395
let mut file_status = FileStatus :: default ( ) ;
396
396
let mut buf_out = vec ! [ 0u8 ; buf_in. len( ) ] ;
397
- while self . common . rows_to_skip > 0 {
397
+ while self . common . rows_to_skip > 0 && !buf_in . is_empty ( ) {
398
398
let ( res, n_in) = self . read_record ( buf_in, & mut buf_out, & mut file_status) ?;
399
399
buf_in = & buf_in[ n_in..] ;
400
400
if matches ! ( res, ReadRecordOutput :: Record { .. } ) {
401
401
self . common . rows_to_skip -= 1 ;
402
402
}
403
403
}
404
404
405
+ if buf_in. is_empty ( ) {
406
+ return Ok ( vec ! [ ] ) ;
407
+ }
408
+
405
409
let mut buf_out_pos = 0usize ;
406
410
let mut buf_out_row_end: usize = 0 ;
407
411
@@ -490,6 +494,7 @@ impl AligningStateTextBased for CsvReaderState {
490
494
self . read_record ( & in_tmp, & mut out_tmp, & mut file_status) ?;
491
495
} else {
492
496
let last_batch_remain_len = self . out . len ( ) ;
497
+ let rows = self . common . rows ;
493
498
let ( out, _n_in) = self . read_record ( & in_tmp, & mut out_tmp, & mut file_status) ?;
494
499
if let ReadRecordOutput :: Record { num_fields, bytes } = out {
495
500
let data = mem:: take ( & mut self . out ) ;
@@ -502,7 +507,7 @@ impl AligningStateTextBased for CsvReaderState {
502
507
split_info : self . split_info . clone ( ) ,
503
508
batch_id : self . common . batch_id ,
504
509
start_offset_in_split : self . common . offset ,
505
- start_row_in_split : self . common . rows ,
510
+ start_row_in_split : rows,
506
511
start_row_of_split : Some ( 0 ) ,
507
512
} ;
508
513
res. push ( row_batch) ;
0 commit comments