use of com.facebook.presto.sql.planner.plan.WindowNode.Frame.WindowType.RANGE in project presto by prestodb.
the class TestPruneUnreferencedOutputs method windowNodePruning.
/**
* Test that the unreferenced output pruning works correctly when WindowNode is pruned as no downstream operators are consuming the window function output
*/
@Test
public void windowNodePruning() {
FunctionHandle functionHandle = createTestMetadataManager().getFunctionAndTypeManager().lookupFunction("rank", ImmutableList.of());
CallExpression call = call("rank", functionHandle, BIGINT);
WindowNode.Frame frame = new WindowNode.Frame(RANGE, UNBOUNDED_PRECEDING, Optional.empty(), UNBOUNDED_FOLLOWING, Optional.empty(), Optional.empty(), Optional.empty());
assertRuleApplication().on(p -> p.output(ImmutableList.of("user_uuid"), ImmutableList.of(p.variable("user_uuid", VARCHAR)), p.project(Assignments.of(p.variable("user_uuid", VARCHAR), p.variable("user_uuid", VARCHAR)), p.window(new WindowNode.Specification(ImmutableList.of(p.variable("user_uuid", VARCHAR)), Optional.of(new OrderingScheme(ImmutableList.of(new Ordering(p.variable("expr"), SortOrder.ASC_NULLS_LAST), new Ordering(p.variable("random"), SortOrder.ASC_NULLS_LAST))))), ImmutableMap.of(p.variable("rank"), new WindowNode.Function(call, frame, false)), p.project(Assignments.builder().put(p.variable("user_uuid", VARCHAR), p.variable("user_uuid", VARCHAR)).put(p.variable("expr", BIGINT), p.variable("expr", BIGINT)).put(p.variable("random", BIGINT), p.rowExpression("random()")).build(), p.values(p.variable("user_uuid", VARCHAR), p.variable("expr", BIGINT))))))).matches(output(project(project(values("user_uuid")))));
}
Aggregations