public TestSwapAdjacentWindowsBySpecifications() { frame = new WindowNode.Frame( WindowFrame.Type.RANGE, UNBOUNDED_PRECEDING, Optional.empty(), CURRENT_ROW, Optional.empty(), Optional.empty(), Optional.empty()); signature = new Signature( "avg", FunctionKind.WINDOW, ImmutableList.of(), ImmutableList.of(), DOUBLE.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature()), false); }
WindowNode.Frame frame = new WindowNode.Frame( frameType, frameStartType,
FunctionCall functionCall = new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnC.toSymbolReference())); WindowNode.Frame frame = new WindowNode.Frame( WindowFrame.Type.RANGE, FrameBound.Type.UNBOUNDED_PRECEDING,
WindowNode.Frame frame = new WindowNode.Frame(frameType, frameStartType, frameStartSymbol, frameEndType, frameEndSymbol);
frame = new WindowNode.Frame(frame.getType(), frame.getStartType(), canonicalize(frame.getStartValue()), frame.getEndType(), canonicalize(frame.getEndValue()));
@Test public void testWindow() throws Exception { PlanNode node = new WindowNode(newId(), filter(baseTableScan, and( equals(AE, BE), equals(BE, CE), lessThan(CE, number(10)))), ImmutableList.of(A), ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST), new WindowNode.Frame(WindowFrame.Type.RANGE, FrameBound.Type.UNBOUNDED_PRECEDING, Optional.empty(), FrameBound.Type.CURRENT_ROW, Optional.empty()), ImmutableMap.<Symbol, FunctionCall>of(), ImmutableMap.<Symbol, Signature>of(), Optional.empty(), ImmutableSet.of(), 0); Expression effectivePredicate = EffectivePredicateExtractor.extract(node, TYPES); // Pass through assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts( equals(AE, BE), equals(BE, CE), lessThan(CE, number(10)))); }
new FunctionCall(QualifiedName.of("min"), ImmutableList.of(input1.toSymbolReference())), signature, new WindowNode.Frame( WindowFrame.Type.RANGE, UNBOUNDED_PRECEDING, new FunctionCall(QualifiedName.of("min"), ImmutableList.of(input2.toSymbolReference())), signature, new WindowNode.Frame( WindowFrame.Type.RANGE, UNBOUNDED_PRECEDING,
false); FunctionCall functionCall = new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnC.toSymbolReference())); WindowNode.Frame frame = new WindowNode.Frame( WindowFrame.Type.RANGE, FrameBound.Type.UNBOUNDED_PRECEDING,
FunctionCall functionCall = new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnA.toSymbolReference())); // should be columnC WindowNode.Frame frame = new WindowNode.Frame( WindowFrame.Type.RANGE, FrameBound.Type.UNBOUNDED_PRECEDING,
FunctionCall functionCall = new FunctionCall(QualifiedName.of("sum"), ImmutableList.of(columnC.toSymbolReference())); WindowNode.Frame frame = new WindowNode.Frame( WindowFrame.Type.RANGE, FrameBound.Type.UNBOUNDED_PRECEDING,
@Override public WindowNode.Frame getExpectedValue(SymbolAliases aliases) { // synthetize original start/end value to keep the constructor of the frame happy. These are irrelevant for the purpose // of testing the plan structure. Optional<Expression> originalStartValue = startValue.map(alias -> alias.toSymbol(aliases).toSymbolReference()); Optional<Expression> originalEndValue = endValue.map(alias -> alias.toSymbol(aliases).toSymbolReference()); return new WindowNode.Frame( type, startType, startValue.map(alias -> alias.toSymbol(aliases)), endType, endValue.map(alias -> alias.toSymbol(aliases)), originalStartValue, originalEndValue); }
private WindowNode.Frame canonicalize(WindowNode.Frame frame) { return new WindowNode.Frame( frame.getType(), frame.getStartType(), canonicalize(frame.getStartValue()), frame.getEndType(), canonicalize(frame.getEndValue()), frame.getOriginalStartValue(), frame.getOriginalEndValue()); }