@Override public Optional<Decorrelated> visitProject(ProjectNode node, PlanNode reference) { if (isCorrelatedShallowly(node)) { // TODO: handle correlated projection return Optional.empty(); } Optional<Decorrelated> result = decorrelate(node.getSource()); return result.map(decorrelated -> { Assignments.Builder assignments = Assignments.builder() .putAll(node.getAssignments()); // Pull up all symbols used by a filter (except correlation) decorrelated.getCorrelatedPredicates().stream() .flatMap(AstUtils::preOrder) .filter(SymbolReference.class::isInstance) .map(SymbolReference.class::cast) .filter(symbolReference -> !correlation.contains(Symbol.from(symbolReference))) .forEach(symbolReference -> assignments.putIdentity(Symbol.from(symbolReference))); return new Decorrelated( decorrelated.getCorrelatedPredicates(), new ProjectNode( node.getId(), // FIXME should I reuse or not? decorrelated.getDecorrelatedNode(), assignments.build())); }); }
@Override public Optional<Decorrelated> visitProject(ProjectNode node, PlanNode reference) { if (isCorrelatedShallowly(node)) { // TODO: handle correlated projection return Optional.empty(); } Optional<Decorrelated> result = decorrelate(node.getSource()); return result.map(decorrelated -> { Assignments.Builder assignments = Assignments.builder() .putAll(node.getAssignments()); // Pull up all symbols used by a filter (except correlation) decorrelated.getCorrelatedPredicates().stream() .flatMap(AstUtils::preOrder) .filter(SymbolReference.class::isInstance) .map(SymbolReference.class::cast) .filter(symbolReference -> !correlation.contains(Symbol.from(symbolReference))) .forEach(symbolReference -> assignments.putIdentity(Symbol.from(symbolReference))); return new Decorrelated( decorrelated.getCorrelatedPredicates(), new ProjectNode( node.getId(), // FIXME should I reuse or not? decorrelated.getDecorrelatedNode(), assignments.build())); }); }
outputSymbols.putIdentity(symbol);
outputSymbols.putIdentity(symbol);
childAssignments.putIdentity(input);
JoinNode.Type.LEFT, p.project(Assignments.builder() .putIdentity(p.symbol("COL1", BIGINT)) .build(), p.aggregation(builder ->
childAssignments.putIdentity(input);
JoinNode.Type.LEFT, p.project(Assignments.builder() .putIdentity(p.symbol("COL1", BIGINT)) .build(), p.aggregation(builder ->
private static PlanNode addPartitioningNodes(Context context, PlanNode node, Symbol partitionSymbol, KdbTree kdbTree, Expression geometry, Optional<Expression> radius) { Assignments.Builder projections = Assignments.builder(); for (Symbol outputSymbol : node.getOutputSymbols()) { projections.putIdentity(outputSymbol); } ImmutableList.Builder<Expression> partitioningArguments = ImmutableList.<Expression>builder() .add(new Cast(new StringLiteral(KdbTreeUtils.toJson(kdbTree)), KDB_TREE_TYPENAME)) .add(geometry); radius.map(partitioningArguments::add); FunctionCall partitioningFunction = new FunctionCall(QualifiedName.of("spatial_partitions"), partitioningArguments.build()); Symbol partitionsSymbol = context.getSymbolAllocator().newSymbol(partitioningFunction, new ArrayType(INTEGER)); projections.put(partitionsSymbol, partitioningFunction); return new UnnestNode( context.getIdAllocator().getNextId(), new ProjectNode(context.getIdAllocator().getNextId(), node, projections.build()), node.getOutputSymbols(), ImmutableMap.of(partitionsSymbol, ImmutableList.of(partitionSymbol)), Optional.empty()); }
private static PlanNode addPartitioningNodes(Context context, PlanNode node, Symbol partitionSymbol, KdbTree kdbTree, Expression geometry, Optional<Expression> radius) { Assignments.Builder projections = Assignments.builder(); for (Symbol outputSymbol : node.getOutputSymbols()) { projections.putIdentity(outputSymbol); } ImmutableList.Builder<Expression> partitioningArguments = ImmutableList.<Expression>builder() .add(new Cast(new StringLiteral(KdbTreeUtils.toJson(kdbTree)), KDB_TREE_TYPENAME)) .add(geometry); radius.map(partitioningArguments::add); FunctionCall partitioningFunction = new FunctionCall(QualifiedName.of("spatial_partitions"), partitioningArguments.build()); Symbol partitionsSymbol = context.getSymbolAllocator().newSymbol(partitioningFunction, new ArrayType(INTEGER)); projections.put(partitionsSymbol, partitioningFunction); return new UnnestNode( context.getIdAllocator().getNextId(), new ProjectNode(context.getIdAllocator().getNextId(), node, projections.build()), node.getOutputSymbols(), ImmutableMap.of(partitionsSymbol, ImmutableList.of(partitionSymbol)), Optional.empty()); }
public Builder putIdentities(Iterable<Symbol> symbols) { for (Symbol symbol : symbols) { putIdentity(symbol); } return this; }
private static PlanNode addProjection(Context context, PlanNode node, Symbol symbol, Expression expression) { Assignments.Builder projections = Assignments.builder(); for (Symbol outputSymbol : node.getOutputSymbols()) { projections.putIdentity(outputSymbol); } projections.put(symbol, expression); return new ProjectNode(context.getIdAllocator().getNextId(), node, projections.build()); }
private static PlanNode addProjection(Context context, PlanNode node, Symbol symbol, Expression expression) { Assignments.Builder projections = Assignments.builder(); for (Symbol outputSymbol : node.getOutputSymbols()) { projections.putIdentity(outputSymbol); } projections.put(symbol, expression); return new ProjectNode(context.getIdAllocator().getNextId(), node, projections.build()); }
public Builder putIdentities(Iterable<Symbol> symbols) { for (Symbol symbol : symbols) { putIdentity(symbol); } return this; }