@Override public PlanNode replaceChildren(List<PlanNode> newChildren) { return new WindowNode(getId(), Iterables.getOnlyElement(newChildren), specification, windowFunctions, hashSymbol, prePartitionedInputs, preSortedOrderPrefix); }
public WindowNode window(WindowNode.Specification specification, Map<Symbol, WindowNode.Function> functions, PlanNode source) { return new WindowNode( idAllocator.getNextId(), source, specification, ImmutableMap.copyOf(functions), Optional.empty(), ImmutableSet.of(), 0); }
public WindowNode window(WindowNode.Specification specification, Map<Symbol, WindowNode.Function> functions, Symbol hashSymbol, PlanNode source) { return new WindowNode( idAllocator.getNextId(), source, specification, ImmutableMap.copyOf(functions), Optional.of(hashSymbol), ImmutableSet.of(), 0); }
return new WindowNode( node.getId(), source,
PlanNode prunedWindowNode = new WindowNode( windowNode.getId(), restrictOutputs(idAllocator, windowNode.getSource(), referencedInputs.build())
@Override protected Optional<PlanNode> manipulateAdjacentWindowNodes(WindowNode parent, WindowNode child, Context context) { if (!child.getSpecification().equals(parent.getSpecification()) || dependsOn(parent, child)) { return Optional.empty(); } ImmutableMap.Builder<Symbol, WindowNode.Function> functionsBuilder = ImmutableMap.builder(); functionsBuilder.putAll(parent.getWindowFunctions()); functionsBuilder.putAll(child.getWindowFunctions()); WindowNode mergedWindowNode = new WindowNode( parent.getId(), child.getSource(), parent.getSpecification(), functionsBuilder.build(), parent.getHashSymbol(), parent.getPrePartitionedInputs(), parent.getPreSortedOrderPrefix()); return Optional.of( restrictOutputs(context.getIdAllocator(), mergedWindowNode, ImmutableSet.copyOf(parent.getOutputSymbols())) .orElse(mergedWindowNode)); } }
@Override public PlanNode visitWindow(WindowNode node, RewriteContext<Void> context) { PlanNode source = context.rewrite(node.getSource()); ImmutableMap.Builder<Symbol, WindowNode.Function> functions = ImmutableMap.builder(); for (Map.Entry<Symbol, WindowNode.Function> entry : node.getWindowFunctions().entrySet()) { Symbol symbol = entry.getKey(); FunctionCall canonicalFunctionCall = (FunctionCall) canonicalize(entry.getValue().getFunctionCall()); Signature signature = entry.getValue().getSignature(); WindowNode.Frame canonicalFrame = canonicalize(entry.getValue().getFrame()); functions.put(canonicalize(symbol), new WindowNode.Function(canonicalFunctionCall, signature, canonicalFrame)); } return new WindowNode( node.getId(), source, canonicalizeAndDistinct(node.getSpecification()), functions.build(), canonicalize(node.getHashSymbol()), canonicalize(node.getPrePartitionedInputs()), node.getPreSortedOrderPrefix()); }
WindowNode result = new WindowNode( node.getId(), child.getNode(),
@Override public PlanWithProperties visitWindow(WindowNode node, HashComputationSet parentPreference) { if (node.getPartitionBy().isEmpty()) { return planSimpleNodeWithProperties(node, parentPreference, true); } Optional<HashComputation> hashComputation = computeHash(node.getPartitionBy()); PlanWithProperties child = planAndEnforce( node.getSource(), new HashComputationSet(hashComputation), true, parentPreference.withHashComputation(node, hashComputation)); Symbol hashSymbol = child.getRequiredHashSymbol(hashComputation.get()); return new PlanWithProperties( new WindowNode( node.getId(), child.getNode(), node.getSpecification(), node.getWindowFunctions(), Optional.of(hashSymbol), node.getPrePartitionedInputs(), node.getPreSortedOrderPrefix()), child.getHashSymbols()); }
new WindowNode( idAllocator.getNextId(), subPlan.getRoot(),
PlanNode node = new WindowNode( newId(), baseTableScan,
PlanNode node = new WindowNode( newId(), baseTableScan,
PlanNode node = new WindowNode( newId(), baseTableScan,
Optional<Symbol> hashSymbol = Optional.of(columnB); Set<Symbol> prePartitionedInputs = ImmutableSet.of(columnA); WindowNode windowNode = new WindowNode( id, sourceNode,
@Test public void testWindow() { PlanNode node = new WindowNode(newId(), filter(baseTableScan, and( equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), new WindowNode.Specification( ImmutableList.of(A), Optional.of(new OrderingScheme( ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST)))), ImmutableMap.of(), Optional.empty(), ImmutableSet.of(), 0); Expression effectivePredicate = effectivePredicateExtractor.extract(node); // Pass through assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts( equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))); }
return new WindowNode( node.getId(), source,
frame.getEndType(), canonicalize(frame.getEndValue())); return new WindowNode( node.getId(), source,
@Override public PlanNode visitWindow(WindowNode node, List<PlanNode> newChildren) { return new WindowNode( node.getId(), Iterables.getOnlyElement(newChildren), node.getPartitionBy(), node.getOrderBy(), node.getOrderings(), node.getFrame(), node.getWindowFunctions(), node.getSignatures(), node.getHashSymbol(), node.getPrePartitionedInputs(), node.getPreSortedOrderPrefix()); }
@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)))); }
return new WindowNode(idAllocator.getNextId(), hashProjectNode, node.getPartitionBy(),