@@ -684,16 +684,19 @@ impl protobuf::PhysicalPlanNode {
684684 } ) ?;
685685
686686 let filter_selectivity = filter. default_filter_selectivity . try_into ( ) ;
687- let projection = if !filter. projection . is_empty ( ) {
688- Some (
689- filter
690- . projection
691- . iter ( )
692- . map ( |i| * i as usize )
693- . collect :: < Vec < _ > > ( ) ,
694- )
695- } else {
687+ let mut projection = Vec :: with_capacity ( filter. projection . len ( ) ) ;
688+ let mut is_full_projection =
689+ filter. projection . len ( ) == input. schema ( ) . fields . len ( ) ;
690+ for ( i, & idx) in filter. projection . iter ( ) . enumerate ( ) {
691+ let idx = idx as usize ;
692+ is_full_projection &= idx == i;
693+ projection. push ( idx) ;
694+ }
695+ let projection = if is_full_projection {
696+ // Store None instead of continuous numbers vector.
696697 None
698+ } else {
699+ Some ( projection)
697700 } ;
698701
699702 let filter = FilterExecBuilder :: new ( predicate, input)
@@ -2364,9 +2367,10 @@ impl protobuf::PhysicalPlanNode {
23642367 . physical_expr_to_proto ( exec. predicate ( ) , codec) ?,
23652368 ) ,
23662369 default_filter_selectivity : exec. default_selectivity ( ) as u32 ,
2367- projection : exec. projection ( ) . as_ref ( ) . map_or_else ( Vec :: new, |v| {
2368- v. iter ( ) . map ( |x| * x as u32 ) . collect :: < Vec < u32 > > ( )
2369- } ) ,
2370+ projection : exec. projection ( ) . as_ref ( ) . map_or (
2371+ ( 0 ..exec. schema ( ) . fields ( ) . len ( ) as u32 ) . collect :: < Vec < u32 > > ( ) ,
2372+ |v| v. iter ( ) . map ( |x| * x as u32 ) . collect :: < Vec < u32 > > ( ) ,
2373+ ) ,
23702374 batch_size : exec. batch_size ( ) as u32 ,
23712375 fetch : exec. fetch ( ) . map ( |f| f as u32 ) ,
23722376 } ,
0 commit comments