use of io.prestosql.sql.relational.Expressions.variable 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