1414package io .trino .sql .planner .iterative .rule ;
1515
1616import com .google .common .collect .ImmutableList ;
17+ import com .google .common .collect .ImmutableMap ;
1718import com .google .common .collect .ImmutableSet ;
1819import com .google .common .collect .Streams ;
1920import io .trino .Session ;
3637import io .trino .sql .planner .plan .ProjectNode ;
3738import org .assertj .core .util .VisibleForTesting ;
3839
39- import java .util .HashMap ;
4040import java .util .HashSet ;
4141import java .util .List ;
4242import java .util .Map ;
@@ -328,7 +328,7 @@ private PlanNode replaceJoin(
328328
329329 private PlanNode toIntermediateAggregation (AggregationNode partialAggregation , PlanNode source , Context context )
330330 {
331- Map <Symbol , AggregationNode . Aggregation > intermediateAggregation = new HashMap <> ();
331+ ImmutableMap . Builder <Symbol , Aggregation > intermediateAggregation = ImmutableMap . builder ();
332332 for (Map .Entry <Symbol , AggregationNode .Aggregation > entry : partialAggregation .getAggregations ().entrySet ()) {
333333 AggregationNode .Aggregation aggregation = entry .getValue ();
334334 ResolvedFunction resolvedFunction = aggregation .getResolvedFunction ();
@@ -353,7 +353,7 @@ private PlanNode toIntermediateAggregation(AggregationNode partialAggregation, P
353353 return new AggregationNode (
354354 context .getIdAllocator ().getNextId (),
355355 source ,
356- intermediateAggregation ,
356+ intermediateAggregation . buildOrThrow () ,
357357 partialAggregation .getGroupingSets (),
358358 // preGroupedSymbols reflect properties of the input. Splitting the aggregation and pushing partial aggregation
359359 // through the join may or may not preserve these properties. Hence, it is safest to drop preGroupedSymbols here.
0 commit comments