Search in sources :

Example 11 with Assignments

use of io.prestosql.spi.plan.Assignments in project hetu-core by openlookeng.

the class InlineProjections method apply.

@Override
public Result apply(ProjectNode parent, Captures captures, Context context) {
    ProjectNode child = captures.get(CHILD);
    Sets.SetView<Symbol> targets = extractInliningTargets(parent, child);
    if (targets.isEmpty()) {
        return Result.empty();
    }
    // inline the expressions
    Assignments assignments = child.getAssignments().filter(targets::contains);
    Map<Symbol, RowExpression> parentAssignments = parent.getAssignments().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (inlineReferences(entry.getValue(), assignments))));
    // Synthesize identity assignments for the inputs of expressions that were inlined
    // to place in the child projection.
    // If all assignments end up becoming identity assignments, they'll get pruned by
    // other rules
    Set<Symbol> inputs = child.getAssignments().entrySet().stream().filter(entry -> targets.contains(entry.getKey())).map(Map.Entry::getValue).flatMap(entry -> extractInputs(entry).stream()).collect(toSet());
    Assignments.Builder childAssignments = Assignments.builder();
    for (Map.Entry<Symbol, RowExpression> assignment : child.getAssignments().entrySet()) {
        if (!targets.contains(assignment.getKey())) {
            childAssignments.put(assignment);
        }
    }
    boolean allTranslated = child.getAssignments().entrySet().stream().map(Map.Entry::getValue).noneMatch(OriginalExpressionUtils::isExpression);
    for (Symbol input : inputs) {
        if (allTranslated) {
            Type inputType = context.getSymbolAllocator().getSymbols().get(input);
            childAssignments.put(input, new VariableReferenceExpression(input.getName(), inputType));
        } else {
            childAssignments.put(input, castToRowExpression(toSymbolReference(input)));
        }
    }
    return Result.ofPlanNode(new ProjectNode(parent.getId(), new ProjectNode(child.getId(), child.getSource(), childAssignments.build()), Assignments.copyOf(parentAssignments)));
}
Also used : Patterns.source(io.prestosql.sql.planner.plan.Patterns.source) ConstantExpression(io.prestosql.spi.relation.ConstantExpression) ExpressionSymbolInliner.inlineSymbols(io.prestosql.sql.planner.ExpressionSymbolInliner.inlineSymbols) Literal(io.prestosql.sql.tree.Literal) TryFunction(io.prestosql.operator.scalar.TryFunction) Pattern(io.prestosql.matching.Pattern) RowExpressionVariableInliner(io.prestosql.sql.planner.RowExpressionVariableInliner) Function(java.util.function.Function) OriginalExpressionUtils.isExpression(io.prestosql.sql.relational.OriginalExpressionUtils.isExpression) CallExpression(io.prestosql.spi.relation.CallExpression) Capture.newCapture(io.prestosql.matching.Capture.newCapture) Map(java.util.Map) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) Type(io.prestosql.spi.type.Type) OriginalExpressionUtils.castToExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToExpression) Patterns.project(io.prestosql.sql.planner.plan.Patterns.project) Collectors.toSet(java.util.stream.Collectors.toSet) Symbol(io.prestosql.spi.plan.Symbol) ImmutableSet(com.google.common.collect.ImmutableSet) SymbolsExtractor(io.prestosql.sql.planner.SymbolsExtractor) Assignments(io.prestosql.spi.plan.Assignments) Rule(io.prestosql.sql.planner.iterative.Rule) DefaultRowExpressionTraversalVisitor(io.prestosql.expressions.DefaultRowExpressionTraversalVisitor) Set(java.util.Set) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ProjectNode(io.prestosql.spi.plan.ProjectNode) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Metadata(io.prestosql.metadata.Metadata) Captures(io.prestosql.matching.Captures) SymbolUtils.toSymbolReference(io.prestosql.sql.planner.SymbolUtils.toSymbolReference) AstUtils(io.prestosql.sql.util.AstUtils) List(java.util.List) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) Capture(io.prestosql.matching.Capture) RowExpression(io.prestosql.spi.relation.RowExpression) TryExpression(io.prestosql.sql.tree.TryExpression) AssignmentUtils.isIdentity(io.prestosql.sql.planner.plan.AssignmentUtils.isIdentity) Expression(io.prestosql.sql.tree.Expression) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) Symbol(io.prestosql.spi.plan.Symbol) Assignments(io.prestosql.spi.plan.Assignments) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Type(io.prestosql.spi.type.Type) Sets(com.google.common.collect.Sets) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ProjectNode(io.prestosql.spi.plan.ProjectNode) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) Map(java.util.Map)

Example 12 with Assignments

use of io.prestosql.spi.plan.Assignments in project hetu-core by openlookeng.

the class PushProjectionIntoTableScan method apply.

@Override
public Result apply(ProjectNode project, Captures captures, Context context) {
    TableScanNode tableScan = captures.get(TABLE_SCAN);
    List<ConnectorExpression> projections;
    try {
        projections = project.getAssignments().getExpressions().stream().map(expression -> ConnectorExpressionTranslator.translate(expression)).collect(toImmutableList());
    } catch (UnsupportedOperationException e) {
        // rewritten in terms of the new assignments for the columns passed in #2
        return Result.empty();
    }
    Map<String, ColumnHandle> assignments = tableScan.getAssignments().entrySet().stream().collect(toImmutableMap(entry -> entry.getKey().getName(), Map.Entry::getValue));
    Optional<ProjectionApplicationResult<TableHandle>> result = metadata.applyProjection(context.getSession(), tableScan.getTable(), projections, assignments);
    if (!result.isPresent()) {
        return Result.empty();
    }
    List<Symbol> newScanOutputs = new ArrayList<>();
    Map<Symbol, ColumnHandle> newScanAssignments = new HashMap<>();
    Map<String, Symbol> variableMappings = new HashMap<>();
    for (ProjectionApplicationResult.Assignment assignment : result.get().getAssignments()) {
        Symbol symbol = context.getSymbolAllocator().newSymbol(assignment.getVariable(), assignment.getType());
        newScanOutputs.add(symbol);
        newScanAssignments.put(symbol, assignment.getColumn());
        variableMappings.put(assignment.getVariable(), symbol);
    }
    // TODO: ensure newProjections.size == original projections.size
    List<RowExpression> newProjections = result.get().getProjections().stream().map(expression -> ConnectorExpressionTranslator.translate(expression, variableMappings, new LiteralEncoder(metadata))).collect(toImmutableList());
    Assignments.Builder newProjectionAssignments = Assignments.builder();
    for (int i = 0; i < project.getOutputSymbols().size(); i++) {
        newProjectionAssignments.put(project.getOutputSymbols().get(i), newProjections.get(i));
    }
    return Result.ofPlanNode(new ProjectNode(context.getIdAllocator().getNextId(), TableScanNode.newInstance(tableScan.getId(), result.get().getHandle(), newScanOutputs, newScanAssignments, tableScan.getStrategy(), tableScan.getReuseTableScanMappingId(), tableScan.getConsumerTableScanNodeCount(), tableScan.isForDelete()), newProjectionAssignments.build()));
}
Also used : Patterns.source(io.prestosql.sql.planner.plan.Patterns.source) ProjectionApplicationResult(io.prestosql.spi.connector.ProjectionApplicationResult) HashMap(java.util.HashMap) Pattern(io.prestosql.matching.Pattern) TableHandle(io.prestosql.spi.metadata.TableHandle) ArrayList(java.util.ArrayList) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) ConnectorExpressionTranslator(io.prestosql.spi.expression.ConnectorExpressionTranslator) Capture.newCapture(io.prestosql.matching.Capture.newCapture) Map(java.util.Map) Patterns.project(io.prestosql.sql.planner.plan.Patterns.project) Symbol(io.prestosql.spi.plan.Symbol) Assignments(io.prestosql.spi.plan.Assignments) Rule(io.prestosql.sql.planner.iterative.Rule) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TableScanNode(io.prestosql.spi.plan.TableScanNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) Metadata(io.prestosql.metadata.Metadata) Captures(io.prestosql.matching.Captures) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Capture(io.prestosql.matching.Capture) RowExpression(io.prestosql.spi.relation.RowExpression) LiteralEncoder(io.prestosql.sql.planner.LiteralEncoder) Optional(java.util.Optional) Patterns.tableScan(io.prestosql.sql.planner.plan.Patterns.tableScan) ConnectorExpression(io.prestosql.spi.expression.ConnectorExpression) HashMap(java.util.HashMap) ConnectorExpression(io.prestosql.spi.expression.ConnectorExpression) Symbol(io.prestosql.spi.plan.Symbol) ArrayList(java.util.ArrayList) Assignments(io.prestosql.spi.plan.Assignments) LiteralEncoder(io.prestosql.sql.planner.LiteralEncoder) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) RowExpression(io.prestosql.spi.relation.RowExpression) ProjectionApplicationResult(io.prestosql.spi.connector.ProjectionApplicationResult) TableScanNode(io.prestosql.spi.plan.TableScanNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap)

Example 13 with Assignments

use of io.prestosql.spi.plan.Assignments in project hetu-core by openlookeng.

the class PushProjectionThroughUnion method apply.

@Override
public Result apply(ProjectNode parent, Captures captures, Context context) {
    UnionNode source = captures.get(CHILD);
    // OutputLayout of the resultant Union, will be same as the layout of the Project
    List<Symbol> outputLayout = parent.getOutputSymbols();
    // Mapping from the output symbol to ordered list of symbols from each of the sources
    ImmutableListMultimap.Builder<Symbol, Symbol> mappings = ImmutableListMultimap.builder();
    // sources for the resultant UnionNode
    ImmutableList.Builder<PlanNode> outputSources = ImmutableList.builder();
    for (int i = 0; i < source.getSources().size(); i++) {
        // Map: output of union -> input of this source to the union
        Map<Symbol, SymbolReference> outputToInput = sourceSymbolMap(source, i);
        // assignments for the new ProjectNode
        Assignments.Builder assignments = Assignments.builder();
        // mapping from current ProjectNode to new ProjectNode, used to identify the output layout
        Map<Symbol, Symbol> projectSymbolMapping = new HashMap<>();
        // Translate the assignments in the ProjectNode using symbols of the source of the UnionNode
        for (Map.Entry<Symbol, RowExpression> entry : parent.getAssignments().entrySet()) {
            RowExpression translatedExpression;
            Map<VariableReferenceExpression, VariableReferenceExpression> variable = new HashMap<>();
            Map<Symbol, Type> symbols = context.getSymbolAllocator().getSymbols();
            for (Symbol symbolMap : source.getSymbolMapping().keySet()) {
                Symbol symboli = source.getSymbolMapping().get(symbolMap).get(i);
                variable.put(new VariableReferenceExpression(symbolMap.getName(), symbols.get(symbolMap)), new VariableReferenceExpression(symboli.getName(), symbols.get(symboli)));
            }
            translatedExpression = RowExpressionVariableInliner.inlineVariables(variable, entry.getValue());
            Symbol symbol = context.getSymbolAllocator().newSymbol(translatedExpression);
            assignments.put(symbol, translatedExpression);
            projectSymbolMapping.put(entry.getKey(), symbol);
        }
        outputSources.add(new ProjectNode(context.getIdAllocator().getNextId(), source.getSources().get(i), assignments.build()));
        outputLayout.forEach(symbol -> mappings.put(symbol, projectSymbolMapping.get(symbol)));
    }
    return Result.ofPlanNode(new UnionNode(parent.getId(), outputSources.build(), mappings.build(), ImmutableList.copyOf(mappings.build().keySet())));
}
Also used : HashMap(java.util.HashMap) Symbol(io.prestosql.spi.plan.Symbol) ImmutableList(com.google.common.collect.ImmutableList) SymbolReference(io.prestosql.sql.tree.SymbolReference) Assignments(io.prestosql.spi.plan.Assignments) RowExpression(io.prestosql.spi.relation.RowExpression) Type(io.prestosql.spi.type.Type) PlanNode(io.prestosql.spi.plan.PlanNode) UnionNode(io.prestosql.spi.plan.UnionNode) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) ProjectNode(io.prestosql.spi.plan.ProjectNode) SetOperationNodeUtils.sourceSymbolMap(io.prestosql.sql.planner.optimizations.SetOperationNodeUtils.sourceSymbolMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with Assignments

use of io.prestosql.spi.plan.Assignments in project hetu-core by openlookeng.

the class TransformCorrelatedInPredicateToJoin method apply.

@Override
public Result apply(ApplyNode apply, Captures captures, Context context) {
    Assignments subqueryAssignments = apply.getSubqueryAssignments();
    if (subqueryAssignments.size() != 1) {
        return Result.empty();
    }
    Expression assignmentExpression = castToExpression(getOnlyElement(subqueryAssignments.getExpressions()));
    if (!(assignmentExpression instanceof InPredicate)) {
        return Result.empty();
    }
    InPredicate inPredicate = (InPredicate) assignmentExpression;
    Symbol inPredicateOutputSymbol = getOnlyElement(subqueryAssignments.getSymbols());
    return apply(apply, inPredicate, inPredicateOutputSymbol, context.getLookup(), context.getIdAllocator(), context.getSymbolAllocator());
}
Also used : CallExpression(io.prestosql.spi.relation.CallExpression) OriginalExpressionUtils.castToRowExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression) OriginalExpressionUtils.castToExpression(io.prestosql.sql.relational.OriginalExpressionUtils.castToExpression) SearchedCaseExpression(io.prestosql.sql.tree.SearchedCaseExpression) NotExpression(io.prestosql.sql.tree.NotExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Expression(io.prestosql.sql.tree.Expression) Symbol(io.prestosql.spi.plan.Symbol) Assignments(io.prestosql.spi.plan.Assignments) InPredicate(io.prestosql.sql.tree.InPredicate)

Example 15 with Assignments

use of io.prestosql.spi.plan.Assignments in project hetu-core by openlookeng.

the class TransformUnCorrelatedInPredicateSubQuerySelfJoinToAggregate method transformProjectNode.

private Optional<ProjectNode> transformProjectNode(Context context, ProjectNode projectNode) {
    // IN predicate requires only one projection
    if (projectNode.getOutputSymbols().size() > 1) {
        return Optional.empty();
    }
    PlanNode source = context.getLookup().resolve(projectNode.getSource());
    if (source instanceof CTEScanNode) {
        source = getChildFilterNode(context, context.getLookup().resolve(((CTEScanNode) source).getSource()));
    }
    if (!(source instanceof FilterNode && context.getLookup().resolve(((FilterNode) source).getSource()) instanceof JoinNode)) {
        return Optional.empty();
    }
    FilterNode filter = (FilterNode) source;
    Expression predicate = OriginalExpressionUtils.castToExpression(filter.getPredicate());
    List<SymbolReference> allPredicateSymbols = new ArrayList<>();
    getAllSymbols(predicate, allPredicateSymbols);
    JoinNode joinNode = (JoinNode) context.getLookup().resolve(((FilterNode) source).getSource());
    if (!isSelfJoin(projectNode, predicate, joinNode, context.getLookup())) {
        // Check next level for Self Join
        PlanNode left = context.getLookup().resolve(joinNode.getLeft());
        boolean changed = false;
        if (left instanceof ProjectNode) {
            Optional<ProjectNode> transformResult = transformProjectNode(context, (ProjectNode) left);
            if (transformResult.isPresent()) {
                joinNode = new JoinNode(joinNode.getId(), joinNode.getType(), transformResult.get(), joinNode.getRight(), joinNode.getCriteria(), joinNode.getOutputSymbols(), joinNode.getFilter(), joinNode.getLeftHashSymbol(), joinNode.getRightHashSymbol(), joinNode.getDistributionType(), joinNode.isSpillable(), joinNode.getDynamicFilters());
                changed = true;
            }
        }
        PlanNode right = context.getLookup().resolve(joinNode.getRight());
        if (right instanceof ProjectNode) {
            Optional<ProjectNode> transformResult = transformProjectNode(context, (ProjectNode) right);
            if (transformResult.isPresent()) {
                joinNode = new JoinNode(joinNode.getId(), joinNode.getType(), joinNode.getLeft(), transformResult.get(), joinNode.getCriteria(), joinNode.getOutputSymbols(), joinNode.getFilter(), joinNode.getLeftHashSymbol(), joinNode.getRightHashSymbol(), joinNode.getDistributionType(), joinNode.isSpillable(), joinNode.getDynamicFilters());
                changed = true;
            }
        }
        if (changed) {
            FilterNode transformedFilter = new FilterNode(filter.getId(), joinNode, filter.getPredicate());
            ProjectNode transformedProject = new ProjectNode(projectNode.getId(), transformedFilter, projectNode.getAssignments());
            return Optional.of(transformedProject);
        }
        return Optional.empty();
    }
    // Choose the table to use based on projected output.
    TableScanNode leftTable = (TableScanNode) context.getLookup().resolve(joinNode.getLeft());
    TableScanNode rightTable = (TableScanNode) context.getLookup().resolve(joinNode.getRight());
    TableScanNode tableToUse;
    List<RowExpression> aggregationSymbols;
    AggregationNode.GroupingSetDescriptor groupingSetDescriptor;
    Assignments projectionsForCTE = null;
    Assignments projectionsFromFilter = null;
    // Use non-projected column for aggregation
    if (context.getLookup().resolve(projectNode.getSource()) instanceof CTEScanNode) {
        CTEScanNode cteScanNode = (CTEScanNode) context.getLookup().resolve(projectNode.getSource());
        ProjectNode childProjectOfCte = (ProjectNode) context.getLookup().resolve(cteScanNode.getSource());
        List<Symbol> completeOutputSymbols = new ArrayList<>();
        rightTable.getOutputSymbols().forEach((s) -> completeOutputSymbols.add(s));
        leftTable.getOutputSymbols().forEach((s) -> completeOutputSymbols.add(s));
        List<Symbol> outputSymbols = new ArrayList<>();
        for (int i = 0; i < completeOutputSymbols.size(); i++) {
            Symbol outputSymbol = completeOutputSymbols.get(i);
            for (Symbol symbol : projectNode.getOutputSymbols()) {
                if (childProjectOfCte.getAssignments().getMap().containsKey(symbol)) {
                    if (((SymbolReference) OriginalExpressionUtils.castToExpression(childProjectOfCte.getAssignments().getMap().get(symbol))).getName().equals(outputSymbol.getName())) {
                        outputSymbols.add(outputSymbol);
                    }
                }
            }
        }
        Map<Symbol, RowExpression> projectionsForCTEMap = new HashMap<>();
        Map<Symbol, RowExpression> projectionsFromFilterMap = new HashMap<>();
        for (Map.Entry entry : childProjectOfCte.getAssignments().getMap().entrySet()) {
            if (entry.getKey().equals(getOnlyElement(projectNode.getOutputSymbols()))) {
                projectionsForCTEMap.put((Symbol) entry.getKey(), (RowExpression) entry.getValue());
            }
            if (entry.getKey().equals(getOnlyElement(projectNode.getOutputSymbols()))) {
                projectionsFromFilterMap.put(getOnlyElement(outputSymbols), (RowExpression) entry.getValue());
            }
        }
        projectionsForCTE = new Assignments(projectionsForCTEMap);
        projectionsFromFilter = new Assignments(projectionsFromFilterMap);
        tableToUse = leftTable.getOutputSymbols().contains(getOnlyElement(outputSymbols)) ? leftTable : rightTable;
        aggregationSymbols = allPredicateSymbols.stream().filter(s -> tableToUse.getOutputSymbols().contains(SymbolUtils.from(s))).filter(s -> !outputSymbols.contains(SymbolUtils.from(s))).map(OriginalExpressionUtils::castToRowExpression).collect(Collectors.toList());
        // Create aggregation
        groupingSetDescriptor = new AggregationNode.GroupingSetDescriptor(ImmutableList.copyOf(outputSymbols), 1, ImmutableSet.of());
    } else {
        tableToUse = leftTable.getOutputSymbols().contains(getOnlyElement(projectNode.getOutputSymbols())) ? leftTable : rightTable;
        aggregationSymbols = allPredicateSymbols.stream().filter(s -> tableToUse.getOutputSymbols().contains(SymbolUtils.from(s))).filter(s -> !projectNode.getOutputSymbols().contains(SymbolUtils.from(s))).map(OriginalExpressionUtils::castToRowExpression).collect(Collectors.toList());
        // Create aggregation
        groupingSetDescriptor = new AggregationNode.GroupingSetDescriptor(ImmutableList.copyOf(projectNode.getOutputSymbols()), 1, ImmutableSet.of());
    }
    AggregationNode.Aggregation aggregation = new AggregationNode.Aggregation(new CallExpression("count", functionResolution.countFunction(), BIGINT, aggregationSymbols), aggregationSymbols, // mark DISTINCT since NOT_EQUALS predicate
    true, Optional.empty(), Optional.empty(), Optional.empty());
    ImmutableMap.Builder<Symbol, AggregationNode.Aggregation> aggregationsBuilder = ImmutableMap.builder();
    Symbol countSymbol = context.getSymbolAllocator().newSymbol(aggregation.getFunctionCall().getDisplayName(), BIGINT);
    aggregationsBuilder.put(countSymbol, aggregation);
    AggregationNode aggregationNode = new AggregationNode(context.getIdAllocator().getNextId(), tableToUse, aggregationsBuilder.build(), groupingSetDescriptor, ImmutableList.of(), AggregationNode.Step.SINGLE, Optional.empty(), Optional.empty(), AggregationNode.AggregationType.HASH, Optional.empty());
    // Filter rows with count < 1 from aggregation results to match the NOT_EQUALS clause in original query.
    FilterNode filterNode = new FilterNode(context.getIdAllocator().getNextId(), aggregationNode, OriginalExpressionUtils.castToRowExpression(new ComparisonExpression(ComparisonExpression.Operator.GREATER_THAN, SymbolUtils.toSymbolReference(countSymbol), new GenericLiteral("BIGINT", "1"))));
    // Project the aggregated+filtered rows.
    ProjectNode transformedSubquery = new ProjectNode(projectNode.getId(), filterNode, projectNode.getAssignments());
    if (context.getLookup().resolve(projectNode.getSource()) instanceof CTEScanNode) {
        CTEScanNode cteScanNode = (CTEScanNode) context.getLookup().resolve(projectNode.getSource());
        PlanNode projectNodeForCTE = context.getLookup().resolve(cteScanNode.getSource());
        PlanNode projectNodeFromFilter = context.getLookup().resolve(projectNodeForCTE);
        projectNodeFromFilter = new ProjectNode(projectNodeFromFilter.getId(), filterNode, projectionsFromFilter);
        projectNodeForCTE = new ProjectNode(projectNodeForCTE.getId(), projectNodeFromFilter, projectionsForCTE);
        cteScanNode = (CTEScanNode) cteScanNode.replaceChildren(ImmutableList.of(projectNodeForCTE));
        cteScanNode.setOutputSymbols(projectNode.getOutputSymbols());
        transformedSubquery = new ProjectNode(projectNode.getId(), cteScanNode, projectNode.getAssignments());
    }
    return Optional.of(transformedSubquery);
}
Also used : Apply.subQuery(io.prestosql.sql.planner.plan.Patterns.Apply.subQuery) Lookup(io.prestosql.sql.planner.iterative.Lookup) Patterns.applyNode(io.prestosql.sql.planner.plan.Patterns.applyNode) HashMap(java.util.HashMap) Pattern(io.prestosql.matching.Pattern) StandardFunctionResolution(io.prestosql.spi.function.StandardFunctionResolution) CTEScanNode(io.prestosql.spi.plan.CTEScanNode) ArrayList(java.util.ArrayList) AggregationNode(io.prestosql.spi.plan.AggregationNode) CallExpression(io.prestosql.spi.relation.CallExpression) Capture.newCapture(io.prestosql.matching.Capture.newCapture) ImmutableList(com.google.common.collect.ImmutableList) FilterNode(io.prestosql.spi.plan.FilterNode) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Session(io.prestosql.Session) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Patterns.project(io.prestosql.sql.planner.plan.Patterns.project) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) SymbolUtils(io.prestosql.sql.planner.SymbolUtils) LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) ApplyNode(io.prestosql.sql.planner.plan.ApplyNode) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) Rule(io.prestosql.sql.planner.iterative.Rule) Pattern.empty(io.prestosql.matching.Pattern.empty) TableScanNode(io.prestosql.spi.plan.TableScanNode) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) PlanNode(io.prestosql.spi.plan.PlanNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) Collectors(java.util.stream.Collectors) Metadata(io.prestosql.metadata.Metadata) Captures(io.prestosql.matching.Captures) List(java.util.List) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) GenericLiteral(io.prestosql.sql.tree.GenericLiteral) SymbolReference(io.prestosql.sql.tree.SymbolReference) TRANSFORM_SELF_JOIN_TO_GROUPBY(io.prestosql.SystemSessionProperties.TRANSFORM_SELF_JOIN_TO_GROUPBY) Apply.correlation(io.prestosql.sql.planner.plan.Patterns.Apply.correlation) Capture(io.prestosql.matching.Capture) RowExpression(io.prestosql.spi.relation.RowExpression) Optional(java.util.Optional) Expression(io.prestosql.sql.tree.Expression) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) InPredicate(io.prestosql.sql.tree.InPredicate) HashMap(java.util.HashMap) SymbolReference(io.prestosql.sql.tree.SymbolReference) Symbol(io.prestosql.spi.plan.Symbol) FilterNode(io.prestosql.spi.plan.FilterNode) ArrayList(java.util.ArrayList) Assignments(io.prestosql.spi.plan.Assignments) GenericLiteral(io.prestosql.sql.tree.GenericLiteral) PlanNode(io.prestosql.spi.plan.PlanNode) CTEScanNode(io.prestosql.spi.plan.CTEScanNode) CallExpression(io.prestosql.spi.relation.CallExpression) JoinNode(io.prestosql.spi.plan.JoinNode) RowExpression(io.prestosql.spi.relation.RowExpression) AggregationNode(io.prestosql.spi.plan.AggregationNode) ImmutableMap(com.google.common.collect.ImmutableMap) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) TableScanNode(io.prestosql.spi.plan.TableScanNode) CallExpression(io.prestosql.spi.relation.CallExpression) LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Expression(io.prestosql.sql.tree.Expression) ProjectNode(io.prestosql.spi.plan.ProjectNode) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

Assignments (io.prestosql.spi.plan.Assignments)34 ProjectNode (io.prestosql.spi.plan.ProjectNode)31 Symbol (io.prestosql.spi.plan.Symbol)25 PlanNode (io.prestosql.spi.plan.PlanNode)20 Expression (io.prestosql.sql.tree.Expression)18 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)16 Cast (io.prestosql.sql.tree.Cast)15 RowExpression (io.prestosql.spi.relation.RowExpression)14 ImmutableList (com.google.common.collect.ImmutableList)13 Type (io.prestosql.spi.type.Type)13 HashMap (java.util.HashMap)13 Map (java.util.Map)13 AggregationNode (io.prestosql.spi.plan.AggregationNode)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 TableScanNode (io.prestosql.spi.plan.TableScanNode)11 List (java.util.List)11 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)10 Metadata (io.prestosql.metadata.Metadata)10 CallExpression (io.prestosql.spi.relation.CallExpression)10 ArrayList (java.util.ArrayList)10