public ExchangeNode exchange(Consumer<ExchangeBuilder> exchangeBuilderConsumer) { ExchangeBuilder exchangeBuilder = new ExchangeBuilder(); exchangeBuilderConsumer.accept(exchangeBuilder); return exchangeBuilder.build(); }
@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); }
public ExchangeBuilder singleDistributionPartitioningScheme(List<Symbol> outputSymbols) { return partitioningScheme(new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), outputSymbols)); }
.addInputsSet(pb.symbol("i11", BIGINT), pb.symbol("i12", BIGINT), pb.symbol("i13", BIGINT), pb.symbol("i14", BIGINT)) .addInputsSet(pb.symbol("i21", BIGINT), pb.symbol("i22", BIGINT), pb.symbol("i23", BIGINT), pb.symbol("i24", BIGINT)) .fixedHashDistributionParitioningScheme( ImmutableList.of(pb.symbol("o1", BIGINT), pb.symbol("o2", BIGINT), pb.symbol("o3", BIGINT), pb.symbol("o4", BIGINT)), emptyList()) .addSource(pb.values(pb.symbol("i11", BIGINT), pb.symbol("i12", BIGINT), pb.symbol("i13", BIGINT), pb.symbol("i14", BIGINT))) .addSource(pb.values(pb.symbol("i21", BIGINT), pb.symbol("i22", BIGINT), pb.symbol("i23", BIGINT), pb.symbol("i24", BIGINT))))) .withSourceStats(0, PlanNodeStatsEstimate.builder() .setOutputRowCount(10)
.build(), p.exchange(e -> e .addSource( p.values(a, b, h, sortSymbol)) .addInputsSet(a, b, h, sortSymbol) .singleDistributionPartitioningScheme( ImmutableList.of(a, b, h, sortSymbol)) .orderingScheme(orderingScheme))); }) .matches(
c2, new SymbolReference("c")), p.exchange(e -> e .addSource( p.values(a)) .addSource( p.values(b)) .addInputsSet(a) .addInputsSet(b) .singleDistributionPartitioningScheme(c))); }) .matches(
.build(), p.exchange(e -> e .addSource( p.values(a, b, h)) .addInputsSet(a, b, h) .fixedHashDistributionParitioningScheme( ImmutableList.of(a, b, h), ImmutableList.of(b),
public TableFinishNode tableDelete(SchemaTableName schemaTableName, PlanNode deleteSource, Symbol deleteRowId) { TableWriterNode.DeleteHandle deleteHandle = new TableWriterNode.DeleteHandle( new TableHandle( new ConnectorId("testConnector"), new TestingTableHandle()), schemaTableName); return new TableFinishNode( idAllocator.getNextId(), exchange(e -> e .addSource(new DeleteNode( idAllocator.getNextId(), deleteSource, deleteHandle, deleteRowId, ImmutableList.of(deleteRowId))) .addInputsSet(deleteRowId) .singleDistributionPartitioningScheme(deleteRowId)), deleteHandle, deleteRowId, Optional.empty(), Optional.empty()); }
@Test public void testDoesNotFireNarrowingProjection() { tester().assertThat(new PushProjectionThroughExchange()) .on(p -> { Symbol a = p.symbol("a"); Symbol b = p.symbol("b"); Symbol c = p.symbol("c"); return p.project( Assignments.builder() .put(a, a.toSymbolReference()) .put(b, b.toSymbolReference()) .build(), p.exchange(e -> e .addSource(p.values(a, b, c)) .addInputsSet(a, b, c) .singleDistributionPartitioningScheme(a, b, c))); }) .doesNotFire(); }
@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); }
@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); }
public ExchangeBuilder addInputsSet(Symbol... inputs) { return addInputsSet(Arrays.asList(inputs)); }
public ExchangeBuilder singleDistributionPartitioningScheme(Symbol... outputSymbols) { return singleDistributionPartitioningScheme(Arrays.asList(outputSymbols)); }
public ExchangeBuilder fixedHashDistributionParitioningScheme(List<Symbol> outputSymbols, List<Symbol> partitioningSymbols) { return partitioningScheme(new PartitioningScheme(Partitioning.create( FIXED_HASH_DISTRIBUTION, ImmutableList.copyOf(partitioningSymbols)), ImmutableList.copyOf(outputSymbols))); }
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())); }
public ExchangeBuilder fixedHashDistributionParitioningScheme(List<Symbol> outputSymbols, List<Symbol> partitioningSymbols, Symbol hashSymbol) { return partitioningScheme(new PartitioningScheme(Partitioning.create( FIXED_HASH_DISTRIBUTION, ImmutableList.copyOf(partitioningSymbols)), ImmutableList.copyOf(outputSymbols), Optional.of(hashSymbol))); }