Source:
<code>private static Grouping computeGrouping( final PartialDruidQuery partialQuery, final PlannerContext plannerContext, final DruidQuerySignature queryColumns, final RexBuilder rexBuilder, final boolean finalizeAggregations ) { final Aggregate aggregate = partialQuery.getAggregate(); final Project aggregateProject = partialQuery.getAggregateProject(); if (aggregate == null) { return null; } final List<DimensionExpression> dimensions = computeDimensions(partialQuery, plannerContext, queryColumns); final List<Aggregation> aggregations = computeAggregations( partialQuery, plannerContext, queryColumns, rexBuilder, finalizeAggregations ); final RowSignature aggregateRowSignature = RowSignature.from( ImmutableList.copyOf( Iterators.concat( dimensions.stream().map(DimensionExpression::getOutputName).iterator(), aggregations.stream().map(Aggregation::getOutputName).iterator() ) ), aggregate.getRowType() ); <START> DruidQuerySignature aggregateContext = queryColumns.withRowSignature(aggregateRowSignature).asImmutable(); <END> final DimFilter havingFilter = computeHavingFilter( partialQuery, plannerContext, aggregateContext ); if (aggregateProject == null) { return Grouping.create(dimensions, aggregations, havingFilter, aggregateRowSignature); } else { final ProjectRowOrderAndPostAggregations projectRowOrderAndPostAggregations = computePostAggregations( plannerContext, aggregateRowSignature, aggregateProject, "p" ); projectRowOrderAndPostAggregations.postAggregations.forEach( postAggregator -> aggregations.add(Aggregation.create(postAggregator)) ); final ImmutableBitSet aggregateProjectBits = RelOptUtil.InputFinder.bits(aggregateProject.getChildExps(), null); for (int i = dimensions.size() - 1; i >= 0; i--) { final DimensionExpression dimension = dimensions.get(i); if (Parser.parse(dimension.getDruidExpression().getExpression(), plannerContext.getExprMacroTable()) .isLiteral() && !aggregateProjectBits.get(i)) { dimensions.remove(i); } } return Grouping.create( dimensions, aggregations, havingFilter, RowSignature.from(projectRowOrderAndPostAggregations.rowOrder, aggregateProject.getRowType()) ); } }</code><technical_language>explain druidQuerySignature immutable</technical_language>

Target:
private static Grouping computeGrouping( final PartialDruidQuery partialQuery, final PlannerContext plannerContext, final DruidQuerySignature queryColumns, final RexBuilder rexBuilder, final boolean finalizeAggregations ) { final Aggregate aggregate = partialQuery.getAggregate(); final Project aggregateProject = partialQuery.getAggregateProject(); if (aggregate == null) { return null; } final List<DimensionExpression> dimensions = computeDimensions(partialQuery, plannerContext, queryColumns); final List<Aggregation> aggregations = computeAggregations( partialQuery, plannerContext, queryColumns, rexBuilder, finalizeAggregations ); final RowSignature aggregateRowSignature = RowSignature.from( ImmutableList.copyOf( Iterators.concat( dimensions.stream().map(DimensionExpression::getOutputName).iterator(), aggregations.stream().map(Aggregation::getOutputName).iterator() ) ), aggregate.getRowType() ); DruidQuerySignature aggregateSignature = queryColumns.asAggregateSignature(aggregateRowSignature); final DimFilter havingFilter = computeHavingFilter( partialQuery, plannerContext, aggregateSignature ); if (aggregateProject == null) { return Grouping.create(dimensions, aggregations, havingFilter, aggregateRowSignature); } else { final ProjectRowOrderAndPostAggregations projectRowOrderAndPostAggregations = computePostAggregations( plannerContext, aggregateRowSignature, aggregateProject, "p" ); projectRowOrderAndPostAggregations.postAggregations.forEach( postAggregator -> aggregations.add(Aggregation.create(postAggregator)) ); final ImmutableBitSet aggregateProjectBits = RelOptUtil.InputFinder.bits(aggregateProject.getChildExps(), null); for (int i = dimensions.size() - 1; i >= 0; i--) { final DimensionExpression dimension = dimensions.get(i); if (Parser.parse(dimension.getDruidExpression().getExpression(), plannerContext.getExprMacroTable()) .isLiteral() && !aggregateProjectBits.get(i)) { dimensions.remove(i); } } return Grouping.create( dimensions, aggregations, havingFilter, RowSignature.from(projectRowOrderAndPostAggregations.rowOrder, aggregateProject.getRowType()) ); } }