use of io.prestosql.sql.tree.SortItem.Ordering.ASCENDING in project hetu-core by openlookeng.
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")), topNRankingNumber(pattern -> pattern.specification(ImmutableList.of(), ImmutableList.of("regionkey"), ImmutableMap.of("regionkey", ASC_NULLS_LAST)), anyTree(sort(ImmutableList.of(sort("regionkey", ASCENDING, LAST)), any(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")), topNRankingNumber(pattern -> pattern.specification(ImmutableList.of(), ImmutableList.of("regionkey"), ImmutableMap.of("regionkey", ASC_NULLS_LAST)), anyTree(sort(ImmutableList.of(sort("regionkey", ASCENDING, LAST)), any(tableScan("nation", ImmutableMap.of("NAME", "name", "REGIONKEY", "regionkey")))))))).withAlias("row_num", new RowNumberSymbolMatcher())))));
}
use of io.prestosql.sql.tree.SortItem.Ordering.ASCENDING in project hetu-core by openlookeng.
the class TestLogicalPlanner method testOffset.
@Test
public void testOffset() {
assertPlan("SELECT name FROM nation OFFSET 2 ROWS", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name")), filter("row_num > BIGINT '2'", rowNumber(pattern -> pattern.partitionBy(ImmutableList.of()), any(tableScan("nation", ImmutableMap.of("NAME", "name")))).withAlias("row_num", new RowNumberSymbolMatcher())))));
assertPlan("SELECT name FROM nation ORDER BY regionkey OFFSET 2 ROWS", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name")), filter("row_num > BIGINT '2'", rowNumber(pattern -> pattern.partitionBy(ImmutableList.of()), anyTree(sort(ImmutableList.of(sort("regionkey", ASCENDING, LAST)), any(tableScan("nation", ImmutableMap.of("NAME", "name", "REGIONKEY", "regionkey")))))).withAlias("row_num", new RowNumberSymbolMatcher())))));
assertPlan("SELECT name FROM nation ORDER BY regionkey OFFSET 2 ROWS FETCH NEXT 5 ROWS ONLY", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name")), filter("row_num > BIGINT '2'", rowNumber(pattern -> pattern.partitionBy(ImmutableList.of()), any(topN(7, ImmutableList.of(sort("regionkey", ASCENDING, LAST)), TopNNode.Step.FINAL, anyTree(tableScan("nation", ImmutableMap.of("NAME", "name", "REGIONKEY", "regionkey")))))).withAlias("row_num", new RowNumberSymbolMatcher())))));
assertPlan("SELECT name FROM nation OFFSET 2 ROWS FETCH NEXT 5 ROWS ONLY", any(strictProject(ImmutableMap.of("name", new ExpressionMatcher("name")), filter("row_num > BIGINT '2'", rowNumber(pattern -> pattern.partitionBy(ImmutableList.of()), limit(7, any(tableScan("nation", ImmutableMap.of("NAME", "name"))))).withAlias("row_num", new RowNumberSymbolMatcher())))));
}
use of io.prestosql.sql.tree.SortItem.Ordering.ASCENDING in project hetu-core by openlookeng.
the class TestPushTopNThroughProject method testPushdownTopNNonIdentityProjectionWithExpression.
@Test
public void testPushdownTopNNonIdentityProjectionWithExpression() {
Signature signature = internalOperator(OperatorType.ADD, BIGINT.getTypeSignature(), BIGINT.getTypeSignature());
FunctionResolution functionResolution = new FunctionResolution(METADATA.getFunctionAndTypeManager());
tester().assertThat(new PushTopNThroughProject()).on(p -> {
Symbol projectedA = p.symbol("projectedA");
Symbol a = p.symbol("a");
Symbol projectedC = p.symbol("projectedC");
Symbol b = p.symbol("b");
return p.topN(1, ImmutableList.of(projectedA), p.project(Assignments.of(projectedA, p.variable("a"), projectedC, call(OperatorType.ADD.name(), functionResolution.arithmeticFunction(OperatorType.ADD, BIGINT, BIGINT), BIGINT, Expressions.variable("a", BIGINT), Expressions.variable("b", BIGINT))), p.values(a, b)));
}).matches(project(ImmutableMap.of("projectedA", new ExpressionMatcher("a"), "projectedC", new ExpressionMatcher("a + b")), topN(1, ImmutableList.of(sort("a", ASCENDING, FIRST)), values("a", "b"))));
}
Aggregations