@@ -490,22 +490,46 @@ impl<'a> RecordBatchDecoder<'a> {
490
490
self . skip_field ( field, & mut variadic_counts) ?;
491
491
}
492
492
}
493
- assert ! ( variadic_counts . is_empty ( ) ) ;
493
+
494
494
arrays. sort_by_key ( |t| t. 0 ) ;
495
- RecordBatch :: try_new_with_options (
496
- Arc :: new ( schema. project ( projection) ?) ,
497
- arrays. into_iter ( ) . map ( |t| t. 1 ) . collect ( ) ,
498
- & options,
499
- )
495
+
496
+ let schema = Arc :: new ( schema. project ( projection) ?) ;
497
+ let columns = arrays. into_iter ( ) . map ( |t| t. 1 ) . collect :: < Vec < _ > > ( ) ;
498
+
499
+ if self . skip_validation . get ( ) {
500
+ // Safety: setting `skip_validation` requires `unsafe`, user assures data is valid
501
+ unsafe {
502
+ Ok ( RecordBatch :: new_unchecked (
503
+ schema,
504
+ columns,
505
+ self . batch . length ( ) as usize ,
506
+ ) )
507
+ }
508
+ } else {
509
+ assert ! ( variadic_counts. is_empty( ) ) ;
510
+ RecordBatch :: try_new_with_options ( schema, columns, & options)
511
+ }
500
512
} else {
501
513
let mut children = vec ! [ ] ;
502
514
// keep track of index as lists require more than one node
503
515
for field in schema. fields ( ) {
504
516
let child = self . create_array ( field, & mut variadic_counts) ?;
505
517
children. push ( child) ;
506
518
}
507
- assert ! ( variadic_counts. is_empty( ) ) ;
508
- RecordBatch :: try_new_with_options ( schema, children, & options)
519
+
520
+ if self . skip_validation . get ( ) {
521
+ // Safety: setting `skip_validation` requires `unsafe`, user assures data is valid
522
+ unsafe {
523
+ Ok ( RecordBatch :: new_unchecked (
524
+ schema,
525
+ children,
526
+ self . batch . length ( ) as usize ,
527
+ ) )
528
+ }
529
+ } else {
530
+ assert ! ( variadic_counts. is_empty( ) ) ;
531
+ RecordBatch :: try_new_with_options ( schema, children, & options)
532
+ }
509
533
}
510
534
}
511
535
0 commit comments