@@ -568,32 +568,32 @@ fn get_indices(
568
568
// some fields are missing, but they might be nullable or metadata columns, need to insert them into the reorder_indices
569
569
for ( requested_position, field) in requested_schema. fields ( ) . enumerate ( ) {
570
570
if !found_fields. contains ( field. name ( ) ) {
571
- if let Some ( metadata_spec) = field. get_metadata_column_spec ( ) {
572
- match metadata_spec {
573
- MetadataColumnSpec :: RowIndex => {
574
- debug ! ( "Inserting a row index column: {}" , field. name( ) ) ;
575
- reorder_indices. push ( ReorderIndex :: row_index (
576
- requested_position,
577
- Arc :: new ( field. try_into_arrow ( ) ?) ,
578
- ) ) ;
579
- }
580
- _ => {
581
- return Err ( Error :: Generic ( format ! (
582
- "Metadata column {metadata_spec:?} is not supported by the default parquet reader"
583
- ) ) ) ;
584
- }
571
+ match field. get_metadata_column_spec ( ) {
572
+ Some ( MetadataColumnSpec :: RowIndex ) => {
573
+ debug ! ( "Inserting a row index column: {}" , field. name( ) ) ;
574
+ reorder_indices. push ( ReorderIndex :: row_index (
575
+ requested_position,
576
+ Arc :: new ( field. try_into_arrow ( ) ?) ,
577
+ ) ) ;
578
+ }
579
+ Some ( metadata_spec) => {
580
+ return Err ( Error :: Generic ( format ! (
581
+ "Metadata column {metadata_spec:?} is not supported by the default parquet reader"
582
+ ) ) ) ;
583
+ }
584
+ None if field. nullable => {
585
+ debug ! ( "Inserting missing and nullable field: {}" , field. name( ) ) ;
586
+ reorder_indices. push ( ReorderIndex :: missing (
587
+ requested_position,
588
+ Arc :: new ( field. try_into_arrow ( ) ?) ,
589
+ ) ) ;
590
+ }
591
+ None => {
592
+ return Err ( Error :: Generic ( format ! (
593
+ "Requested field not found in parquet schema, and field is not nullable: {}" ,
594
+ field. name( )
595
+ ) ) ) ;
585
596
}
586
- } else if field. nullable {
587
- debug ! ( "Inserting missing and nullable field: {}" , field. name( ) ) ;
588
- reorder_indices. push ( ReorderIndex :: missing (
589
- requested_position,
590
- Arc :: new ( field. try_into_arrow ( ) ?) ,
591
- ) ) ;
592
- } else {
593
- return Err ( Error :: Generic ( format ! (
594
- "Requested field not found in parquet schema, and field is not nullable: {}" ,
595
- field. name( )
596
- ) ) ) ;
597
597
}
598
598
}
599
599
}
@@ -821,15 +821,12 @@ pub(crate) fn reorder_struct_array(
821
821
row_indexes. take ( num_rows) . collect ( ) ;
822
822
require ! (
823
823
row_index_array. len( ) == num_rows,
824
- Error :: internal_error( format!(
825
- "Row index iterator exhausted after only {} of {} rows" ,
826
- row_index_array. len( ) ,
827
- num_rows
828
- ) )
824
+ Error :: internal_error(
825
+ "Row index iterator exhausted before reaching the end of the file"
826
+ )
829
827
) ;
830
- let field = field. clone ( ) ; // cheap Arc clone
831
828
final_fields_cols[ reorder_index. index ] =
832
- Some ( ( field, Arc :: new ( row_index_array) ) ) ;
829
+ Some ( ( Arc :: clone ( field) , Arc :: new ( row_index_array) ) ) ;
833
830
}
834
831
}
835
832
}
@@ -856,9 +853,6 @@ fn reorder_list<O: OffsetSizeTrait>(
856
853
let ( list_field, offset_buffer, maybe_sa, null_buf) = list_array. into_parts ( ) ;
857
854
if let Some ( struct_array) = maybe_sa. as_struct_opt ( ) {
858
855
let struct_array = struct_array. clone ( ) ;
859
- // WARNING: We cannot naively plumb through our caller's row index iterator, because each
860
- // array element of a given row must replicate the row's index and empty arrays must drop
861
- // that row's index. For now, just don't support it (Delta doesn't need the capability).
862
856
let result_array = Arc :: new ( reorder_struct_array (
863
857
struct_array,
864
858
children,
0 commit comments