Package com.facebook.presto.sql.planner.plan

Examples of com.facebook.presto.sql.planner.plan.PlanNode


            EqualityInference.EqualityPartition equalityPartition = inheritedInference.generateEqualitiesPartitionedBy(in(node.getSource().getOutputSymbols()));
            sourceConjuncts.addAll(equalityPartition.getScopeEqualities());
            postJoinConjuncts.addAll(equalityPartition.getScopeComplementEqualities());
            postJoinConjuncts.addAll(equalityPartition.getScopeStraddlingEqualities());

            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), combineConjuncts(sourceConjuncts));
            PlanNode rewrittenFilteringSource = planRewriter.rewrite(node.getFilteringSource(), combineConjuncts(filteringSourceConjuncts));

            PlanNode output = node;
            if (rewrittenSource != node.getSource() || rewrittenFilteringSource != node.getFilteringSource()) {
                output = new SemiJoinNode(node.getId(), rewrittenSource, rewrittenFilteringSource, node.getSourceJoinSymbol(), node.getFilteringSourceJoinSymbol(), node.getSemiJoinOutput());
            }
            if (!postJoinConjuncts.isEmpty()) {
                output = new FilterNode(idAllocator.getNextId(), output, combineConjuncts(postJoinConjuncts));
View Full Code Here


            EqualityInference.EqualityPartition equalityPartition = equalityInference.generateEqualitiesPartitionedBy(in(node.getGroupBy()));
            pushdownConjuncts.addAll(equalityPartition.getScopeEqualities());
            postAggregationConjuncts.addAll(equalityPartition.getScopeComplementEqualities());
            postAggregationConjuncts.addAll(equalityPartition.getScopeStraddlingEqualities());

            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), combineConjuncts(pushdownConjuncts));

            PlanNode output = node;
            if (rewrittenSource != node.getSource()) {
                output = new AggregationNode(node.getId(), rewrittenSource, node.getGroupBy(), node.getAggregations(), node.getFunctions(), node.getMasks(), node.getStep());
            }
            if (!postAggregationConjuncts.isEmpty()) {
                output = new FilterNode(idAllocator.getNextId(), output, combineConjuncts(postAggregationConjuncts));
View Full Code Here

            // Do some early partition pruning
            partitions = ImmutableList.copyOf(filter(partitions, not(shouldPrunePartition(postScanPredicate, node.getAssignments()))));
            GeneratedPartitions generatedPartitions = new GeneratedPartitions(tupleDomain, partitions);

            PlanNode output = node;
            if (!node.getGeneratedPartitions().equals(Optional.of(generatedPartitions))) {
                // Only overwrite the originalConstraint if it was previously null
                Expression originalConstraint = node.getOriginalConstraint() == null ? inheritedPredicate : node.getOriginalConstraint();
                output = new TableScanNode(node.getId(), node.getTable(), node.getOutputSymbols(), node.getAssignments(), originalConstraint, Optional.of(generatedPartitions));
            }
View Full Code Here

        public PlanNode rewriteUnion(UnionNode node, Boolean upstreamDistinct, PlanRewriter<Boolean> planRewriter)
        {
            ImmutableList.Builder<PlanNode> flattenedSources = ImmutableList.builder();
            ImmutableListMultimap.Builder<Symbol, Symbol> flattenedSymbolMap = ImmutableListMultimap.builder();
            for (int i = 0; i < node.getSources().size(); i++) {
                PlanNode subplan = node.getSources().get(i);
                PlanNode rewrittenSource = planRewriter.rewrite(subplan, upstreamDistinct);

                if (rewrittenSource instanceof UnionNode) {
                    // Absorb source's subplans if it is also a UnionNode
                    UnionNode rewrittenUnion = (UnionNode) rewrittenSource;
                    flattenedSources.addAll(rewrittenUnion.getSources());
View Full Code Here

        @Override
        public PlanNode rewriteAggregation(AggregationNode node, Boolean upstreamDistinct, PlanRewriter<Boolean> planRewriter)
        {
            boolean distinct = isDistinctOperator(node);

            PlanNode rewrittenNode = planRewriter.rewrite(node.getSource(), distinct);

            if (upstreamDistinct && distinct) {
                // Assumes underlying node has same output symbols as this distinct node
                return rewrittenNode;
            }
View Full Code Here

        }

        @Override
        public PlanNode rewriteNode(PlanNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode rewrittenNode = planRewriter.defaultRewrite(node, Long.MAX_VALUE);
            if (limit != Long.MAX_VALUE) {
                // Drop in a LimitNode b/c we cannot push our limit down any further
                rewrittenNode = new LimitNode(idAllocator.getNextId(), rewrittenNode, limit);
            }
            return rewrittenNode;
View Full Code Here

        }

        @Override
        public PlanNode rewriteTopN(TopNNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), Long.MAX_VALUE);
            if (limit != Long.MAX_VALUE || rewrittenSource != node.getSource()) {
                return new TopNNode(node.getId(), rewrittenSource, Math.min(node.getCount(), limit), node.getOrderBy(), node.getOrderings(), node.isPartial());
            }
            return node;
        }
View Full Code Here

        }

        @Override
        public PlanNode rewriteSort(SortNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), Long.MAX_VALUE);
            if (limit != Long.MAX_VALUE) {
                return new TopNNode(node.getId(), rewrittenSource, limit, node.getOrderBy(), node.getOrderings(), false);
            }
            else if (rewrittenSource != node.getSource()) {
                return new SortNode(node.getId(), rewrittenSource, node.getOrderBy(), node.getOrderings());
View Full Code Here

        }

        @Override
        public PlanNode rewriteUnion(UnionNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode output = planRewriter.defaultRewrite(node, limit);
            if (limit != Long.MAX_VALUE) {
                output = new LimitNode(idAllocator.getNextId(), output, limit);
            }
            return output;
        }
View Full Code Here

        }

        @Override
        public PlanNode rewriteSemiJoin(SemiJoinNode node, Long limit, PlanRewriter<Long> planRewriter)
        {
            PlanNode source = planRewriter.rewrite(node.getSource(), limit);
            if (source != node.getSource()) {
                return new SemiJoinNode(node.getId(), source, node.getFilteringSource(), node.getSourceJoinSymbol(), node.getFilteringSourceJoinSymbol(), node.getSemiJoinOutput());
            }
            return node;
        }
View Full Code Here

TOP

Related Classes of com.facebook.presto.sql.planner.plan.PlanNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.