use of io.prestosql.spi.sql.expression.Types.FrameBoundType.CURRENT_ROW in project hetu-core by openlookeng.
the class TestPruneWindowColumns method buildProjectedWindow.
private static PlanNode buildProjectedWindow(PlanBuilder p, Predicate<Symbol> projectionFilter, Predicate<Symbol> sourceFilter) {
Symbol orderKey = p.symbol("orderKey");
Symbol partitionKey = p.symbol("partitionKey");
Symbol hash = p.symbol("hash");
Symbol startValue1 = p.symbol("startValue1");
Symbol startValue2 = p.symbol("startValue2");
Symbol endValue1 = p.symbol("endValue1");
Symbol endValue2 = p.symbol("endValue2");
Symbol input1 = p.symbol("input1");
Symbol input2 = p.symbol("input2");
Symbol unused = p.symbol("unused");
Symbol output1 = p.symbol("output1");
Symbol output2 = p.symbol("output2");
List<Symbol> inputs = ImmutableList.of(orderKey, partitionKey, hash, startValue1, startValue2, endValue1, endValue2, input1, input2, unused);
List<Symbol> outputs = ImmutableList.<Symbol>builder().addAll(inputs).add(output1, output2).build();
return p.project(Assignments.copyOf(outputs.stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> p.variable(v.getName(), BIGINT)))), p.window(new WindowNode.Specification(ImmutableList.of(partitionKey), Optional.of(new OrderingScheme(ImmutableList.of(orderKey), ImmutableMap.of(orderKey, SortOrder.ASC_NULLS_FIRST)))), ImmutableMap.of(output1, new WindowNode.Function(call(FUNCTION_NAME, FUNCTION_HANDLE, BIGINT, ImmutableList.of(p.variable(input1.getName()))), ImmutableList.of(p.variable(input1.getName())), new WindowNode.Frame(WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.of(startValue1), CURRENT_ROW, Optional.of(endValue1), Optional.of(startValue1.getName()), Optional.of(endValue2.getName()))), output2, new WindowNode.Function(call(FUNCTION_NAME, FUNCTION_HANDLE, BIGINT, ImmutableList.of(p.variable(input2.getName()))), ImmutableList.of(p.variable(input2.getName())), new WindowNode.Frame(WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.of(startValue2), CURRENT_ROW, Optional.of(endValue2), Optional.of(startValue2.getName()), Optional.of(endValue2.getName())))), hash, p.values(inputs.stream().filter(sourceFilter).collect(toImmutableList()), ImmutableList.of())));
}
Aggregations