use of io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL in project trino by trinodb.
the class PropertyDerivations method deriveProperties.
public static ActualProperties deriveProperties(PlanNode node, List<ActualProperties> inputProperties, PlannerContext plannerContext, Session session, TypeProvider types, TypeAnalyzer typeAnalyzer) {
ActualProperties output = node.accept(new Visitor(plannerContext, session, types, typeAnalyzer), inputProperties);
output.getNodePartitioning().ifPresent(partitioning -> verify(node.getOutputSymbols().containsAll(partitioning.getColumns()), "Node-level partitioning properties contain columns not present in node's output"));
verify(node.getOutputSymbols().containsAll(output.getConstants().keySet()), "Node-level constant properties contain columns not present in node's output");
Set<Symbol> localPropertyColumns = output.getLocalProperties().stream().flatMap(property -> property.getColumns().stream()).collect(Collectors.toSet());
verify(node.getOutputSymbols().containsAll(localPropertyColumns), "Node-level local properties contain columns not present in node's output");
return output;
}
use of io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL in project trino by trinodb.
the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.
@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);
}
use of io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL in project trino by trinodb.
the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoinWithoutSeparatingExchange.
@Test
public void testWithPartialAggregationBelowJoinWithoutSeparatingExchange() {
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.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(tableScanNode)), builder.values())));
assertThatThrownBy(() -> validatePlan(root, true)).isInstanceOf(IllegalArgumentException.class).hasMessage("Final aggregation with default value not separated from partial aggregation by local hash exchange");
}
Aggregations