@Test public void testSingleNodeFinalAggregationSeparatedFromPartialAggregationByLocalHashExchange() { Symbol symbol = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.exchange(e -> e .type(REPARTITION) .scope(LOCAL) .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) .addInputsSet(symbol) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))))); validatePlan(root, true); }
@Test public void testGloballyDistributedFinalAggregationSeparatedFromPartialAggregationByRemoteHashExchange() { Symbol symbol = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.exchange(e -> e .type(REPARTITION) .scope(REMOTE) .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) .addInputsSet(symbol) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))))); validatePlan(root, false); }
@Test public void testWithPartialAggregationBelowJoin() { Symbol symbol = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.join( INNER, builder.exchange(e -> e .type(REPARTITION) .scope(LOCAL) .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) .addInputsSet(symbol) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))), builder.values()))); validatePlan(root, true); }
public ExchangeNode gatheringExchange(ExchangeNode.Scope scope, PlanNode child) { return exchange(builder -> builder.type(ExchangeNode.Type.GATHER) .scope(scope) .singleDistributionPartitioningScheme(child.getOutputSymbols()) .addSource(child) .addInputsSet(child.getOutputSymbols())); }