private ImmutableBitSet . Builder getInputFieldUsed ( Aggregate aggregate , RelNode input ) { // 1. group fields are always used final ImmutableBitSet . Builder inputFieldsUsed = aggregate . getGroupSet ( ) . rebuild ( ) ; // 2. agg functions for ( AggregateCall aggCall : aggregate . getAggCallList ( ) ) { for ( int i : aggCall . getArgList ( ) ) { inputFieldsUsed . set ( i ) ; } if ( aggCall . filterArg >= 0 ) { inputFieldsUsed . set ( aggCall . filterArg ) ; } } // 3. window time field if the aggregate is a group window aggregate. if ( aggregate instanceof LogicalWindowAggregate ) { inputFieldsUsed . set ( getWindowTimeFieldIndex ( ( LogicalWindowAggregate ) aggregate , input ) ) ; } return inputFieldsUsed ; }
Compute which input fields are used by the aggregate .