use of io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL in project trino by trinodb.
the class TestLogicalPlanner method testWithTies.
@Test
public void testWithTies() {
assertPlan("SELECT name, regionkey FROM nation ORDER BY regionkey FETCH FIRST 6 ROWS WITH TIES", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name"), "regionkey", new ExpressionMatcher("regionkey")), topNRanking(pattern -> pattern.specification(ImmutableList.of(), ImmutableList.of("regionkey"), ImmutableMap.of("regionkey", SortOrder.ASC_NULLS_LAST)).rankingType(RANK).maxRankingPerPartition(6).partial(false), anyTree(tableScan("nation", ImmutableMap.of("name", "name", "regionkey", "regionkey")))))));
assertPlan("SELECT name, regionkey FROM nation ORDER BY regionkey OFFSET 10 ROWS FETCH FIRST 6 ROWS WITH TIES", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name"), "regionkey", new ExpressionMatcher("regionkey")), filter("row_num > BIGINT '10'", rowNumber(pattern -> pattern.partitionBy(ImmutableList.of()), strictProject(ImmutableMap.of("name", new ExpressionMatcher("name"), "regionkey", new ExpressionMatcher("regionkey")), topNRanking(pattern -> pattern.specification(ImmutableList.of(), ImmutableList.of("regionkey"), ImmutableMap.of("regionkey", SortOrder.ASC_NULLS_LAST)).rankingType(RANK).maxRankingPerPartition(16).partial(false), anyTree(tableScan("nation", ImmutableMap.of("name", "name", "regionkey", "regionkey")))))).withAlias("row_num", new RowNumberSymbolMatcher())))));
}
use of io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL 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.AggregationNode.Step.PARTIAL 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