use of com.facebook.presto.sql.relational.FunctionResolution in project presto by prestodb.
the class TestPushProjectionThroughUnion method test.
@Test
public void test() {
FunctionResolution functionResolution = new FunctionResolution(tester().getMetadata().getFunctionAndTypeManager());
tester().assertThat(new PushProjectionThroughUnion()).on(p -> {
VariableReferenceExpression a = p.variable("a");
VariableReferenceExpression b = p.variable("b");
VariableReferenceExpression c = p.variable("c");
return p.project(assignment(p.variable("c_times_3"), call("c * 3", functionResolution.arithmeticFunction(MULTIPLY, BIGINT, BIGINT), BIGINT, c, constant(3L, BIGINT))), p.union(ImmutableListMultimap.<VariableReferenceExpression, VariableReferenceExpression>builder().put(c, a).put(c, b).build(), ImmutableList.of(p.values(a), p.values(b))));
}).matches(union(project(ImmutableMap.of("a_times_3", expression("a * 3")), values(ImmutableList.of("a"))), project(ImmutableMap.of("b_times_3", expression("b * 3")), values(ImmutableList.of("b")))).withNumberOfOutputColumns(1).withAlias("a_times_3").withAlias("b_times_3"));
}
Aggregations