@@ -32,8 +32,8 @@ use crate::{
3232} ;
3333
3434use arrow:: array:: {
35- new_null_array, Array , ArrayRef , AsArray , FixedSizeListArray , Int64Array ,
36- LargeListArray , ListArray , PrimitiveArray , Scalar , StructArray ,
35+ new_null_array, Array , ArrayRef , AsArray , BooleanBufferBuilder , FixedSizeListArray ,
36+ Int64Array , LargeListArray , ListArray , PrimitiveArray , Scalar , StructArray ,
3737} ;
3838use arrow:: compute:: kernels:: length:: length;
3939use arrow:: compute:: kernels:: zip:: zip;
@@ -111,19 +111,19 @@ impl UnnestExec {
111111 struct_column_indices : & [ usize ] ,
112112 schema : SchemaRef ,
113113 ) -> PlanProperties {
114- let list_column_indices : Vec < usize > = list_column_indices
115- . iter ( )
116- . map ( |list_unnest| list_unnest . index_in_input_schema )
117- . collect ( ) ;
118- let non_unnested_indices : Vec < usize > = input
119- . schema ( )
120- . fields ( )
121- . iter ( )
122- . enumerate ( )
123- . filter ( | ( idx , _ ) | {
124- !list_column_indices . contains ( idx ) && !struct_column_indices . contains ( idx )
125- } )
126- . map ( | ( idx, _ ) | idx)
114+ // Find out which indices are not unnested, such that they can be copied over from the input plan
115+ let input_schema = input . schema ( ) ;
116+ let mut unnested_indices = BooleanBufferBuilder :: new ( input_schema . fields ( ) . len ( ) ) ;
117+ unnested_indices . append_n ( input_schema . fields ( ) . len ( ) , false ) ;
118+ for list_unnest in list_column_indices {
119+ unnested_indices . set_bit ( list_unnest . index_in_input_schema , true ) ;
120+ }
121+ for list_unnest in struct_column_indices {
122+ unnested_indices . set_bit ( * list_unnest , true )
123+ }
124+ let unnested_indices = unnested_indices . finish ( ) ;
125+ let non_unnested_indices : Vec < usize > = ( 0 ..input_schema . fields ( ) . len ( ) )
126+ . filter ( | idx| !unnested_indices . value ( * idx) )
127127 . collect ( ) ;
128128
129129 // Manually build projection mapping from non-unnested input columns to their positions in the output
0 commit comments