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

Examples of com.facebook.presto.sql.planner.plan.JoinNode$EquiJoinClause


                rightAssignments,
                null,
                Optional.<GeneratedPartitions>absent()
        );

        PlanNode node = new JoinNode(newId(),
                JoinNode.Type.INNER,
                filter(leftScan,
                        and(
                                lessThan(BE, AE),
                                lessThan(CE, number(10)))),
View Full Code Here


                rightAssignments,
                null,
                Optional.<GeneratedPartitions>absent()
        );

        PlanNode node = new JoinNode(newId(),
                JoinNode.Type.LEFT,
                filter(leftScan,
                        and(
                                lessThan(BE, AE),
                                lessThan(CE, number(10)))),
View Full Code Here

                rightAssignments,
                null,
                Optional.<GeneratedPartitions>absent()
        );

        PlanNode node = new JoinNode(newId(),
                JoinNode.Type.RIGHT,
                filter(leftScan,
                        and(
                                lessThan(BE, AE),
                                lessThan(CE, number(10)))),
View Full Code Here

                ImmutableList.copyOf(probe.getFragment().getSymbols().keySet()));

        // join build and probe
        PlanFragment joinPlan = new PlanFragment(
                new PlanFragmentId(planId),
                new JoinNode(new PlanNodeId(planId), JoinNode.Type.INNER, probeExchange, buildExchange, ImmutableList.<EquiJoinClause>of()),
                probe.getFragment().getSymbols(), // this is wrong, but it works
                PlanDistribution.SOURCE,
                new PlanNodeId(planId),
                OutputPartitioning.NONE,
                ImmutableList.<Symbol>of());
View Full Code Here

            if (left.isDistributed() || right.isDistributed()) {
                switch (node.getType()) {
                    case INNER:
                    case LEFT:
                        right.setRoot(new SinkNode(idAllocator.getNextId(), right.getRoot(), right.getRoot().getOutputSymbols()));
                        left.setRoot(new JoinNode(node.getId(),
                                node.getType(),
                                left.getRoot(),
                                new ExchangeNode(idAllocator.getNextId(), right.getId(), right.getRoot().getOutputSymbols()),
                                node.getCriteria()));
                        left.addChild(right.build());

                        return left;
                    case RIGHT:
                        left.setRoot(new SinkNode(idAllocator.getNextId(), left.getRoot(), left.getRoot().getOutputSymbols()));
                        right.setRoot(new JoinNode(node.getId(),
                                node.getType(),
                                new ExchangeNode(idAllocator.getNextId(), left.getId(), left.getRoot().getOutputSymbols()),
                                right.getRoot(),
                                node.getCriteria()));
                        right.addChild(left.build());

                        return right;
                    default:
                        throw new UnsupportedOperationException("Unsupported join type: " + node.getType());
                }
            }
            else {
                JoinNode join = new JoinNode(node.getId(), node.getType(), left.getRoot(), right.getRoot(), node.getCriteria());
                return createSingleNodePlan(join)
                        .setChildren(Iterables.concat(left.getChildren(), right.getChildren()));
            }
        }
View Full Code Here

                .addAll(rightPlan.getOutputSymbols())
                .build();

        if (node.getType() == Join.Type.CROSS) {
            return new RelationPlan(
                    new JoinNode(idAllocator.getNextId(),
                            JoinNode.Type.typeConvert(node.getType()),
                            leftPlanBuilder.getRoot(),
                            rightPlanBuilder.getRoot(),
                            ImmutableList.<JoinNode.EquiJoinClause>of()),
                    analysis.getOutputDescriptor(node), outputSymbols);
        }

        List<EquiJoinClause> criteria = analysis.getJoinCriteria(node);
        Analysis.JoinInPredicates joinInPredicates = analysis.getJoinInPredicates(node);

        // Add semi joins if necessary
        if (joinInPredicates != null) {
            leftPlanBuilder = appendSemiJoins(leftPlanBuilder, joinInPredicates.getLeftInPredicates());
            rightPlanBuilder = appendSemiJoins(rightPlanBuilder, joinInPredicates.getRightInPredicates());
        }

        // Add projections for join criteria
        leftPlanBuilder = appendProjections(leftPlanBuilder, Iterables.transform(criteria, leftGetter()));
        rightPlanBuilder = appendProjections(rightPlanBuilder, Iterables.transform(criteria, rightGetter()));

        ImmutableList.Builder<JoinNode.EquiJoinClause> clauses = ImmutableList.builder();
        for (EquiJoinClause clause : criteria) {
            Symbol leftSymbol = leftPlanBuilder.translate(clause.getLeft());
            Symbol rightSymbol = rightPlanBuilder.translate(clause.getRight());

            clauses.add(new JoinNode.EquiJoinClause(leftSymbol, rightSymbol));
        }

        return new RelationPlan(new JoinNode(idAllocator.getNextId(), JoinNode.Type.typeConvert(node.getType()), leftPlanBuilder.getRoot(), rightPlanBuilder.getRoot(), clauses.build()), analysis.getOutputDescriptor(node), outputSymbols);
    }
View Full Code Here

                if (rightSource instanceof MaterializeSampleNode) {
                    rightSampleWeight = ((MaterializeSampleNode) rightSource).getSampleWeightSymbol();
                    rightSource = ((MaterializeSampleNode) rightSource).getSource();
                }

                PlanNode joinNode = new JoinNode(node.getId(), node.getType(), leftSource, rightSource, node.getCriteria());
                Symbol outputSampleWeight;
                if (leftSampleWeight != null && rightSampleWeight != null) {
                    ImmutableMap.Builder<Symbol, Expression> projections = ImmutableMap.builder();
                    Expression sampleWeightExpr;
                    switch (node.getType()) {
                        case INNER:
                        case CROSS:
                            sampleWeightExpr = new ArithmeticExpression(ArithmeticExpression.Type.MULTIPLY, new QualifiedNameReference(leftSampleWeight.toQualifiedName()), new QualifiedNameReference(rightSampleWeight.toQualifiedName()));
                            break;
                        case LEFT:
                            sampleWeightExpr = new ArithmeticExpression(ArithmeticExpression.Type.MULTIPLY, new QualifiedNameReference(leftSampleWeight.toQualifiedName()), oneIfNull(rightSampleWeight));
                            break;
                        case RIGHT:
                            sampleWeightExpr = new ArithmeticExpression(ArithmeticExpression.Type.MULTIPLY, oneIfNull(leftSampleWeight), new QualifiedNameReference(rightSampleWeight.toQualifiedName()));
                            break;
                        default:
                            throw new AssertionError(String.format("Unknown join type: %s", node.getType()));
                    }
                    outputSampleWeight = symbolAllocator.newSymbol(sampleWeightExpr, BIGINT);
                    projections.put(outputSampleWeight, sampleWeightExpr);
                    for (Symbol symbol : Iterables.filter(node.getOutputSymbols(), not(in(ImmutableSet.of(leftSampleWeight, rightSampleWeight))))) {
                        Expression expression = new QualifiedNameReference(symbol.toQualifiedName());
                        projections.put(symbol, expression);
                    }
                    joinNode = new ProjectNode(idAllocator.getNextId(), joinNode, projections.build());
                }
                else {
                    outputSampleWeight = leftSampleWeight == null ? rightSampleWeight : leftSampleWeight;
                    if ((node.getType() == JoinNode.Type.LEFT && leftSampleWeight == null) || (node.getType() == JoinNode.Type.RIGHT && rightSampleWeight == null)) {
                        // There could be NULLs in the sample weight, so fix them with a projection
                        ImmutableMap.Builder<Symbol, Expression> projections = ImmutableMap.builder();
                        for (Symbol symbol : Iterables.filter(node.getOutputSymbols(), not(equalTo(outputSampleWeight)))) {
                            Expression expression = new QualifiedNameReference(symbol.toQualifiedName());
                            projections.put(symbol, expression);
                        }
                        Expression sampleWeightExpr = oneIfNull(outputSampleWeight);
                        outputSampleWeight = symbolAllocator.newSymbol(sampleWeightExpr, BIGINT);
                        projections.put(outputSampleWeight, sampleWeightExpr);
                        joinNode = new ProjectNode(idAllocator.getNextId(), joinNode, projections.build());
                    }
                }
                return new MaterializeSampleNode(idAllocator.getNextId(), joinNode, outputSampleWeight);
            }

            return new JoinNode(node.getId(), node.getType(), leftSource, rightSource, node.getCriteria());
        }
View Full Code Here

        public PlanNode rewriteJoin(JoinNode node, Void context, PlanRewriter<Void> planRewriter)
        {
            PlanNode left = planRewriter.rewrite(node.getLeft(), context);
            PlanNode right = planRewriter.rewrite(node.getRight(), context);

            return new JoinNode(node.getId(), node.getType(), left, right, canonicalizeJoinCriteria(node.getCriteria()));
        }
View Full Code Here

                    .build();

            PlanNode left = planRewriter.rewrite(node.getLeft(), leftInputs);
            PlanNode right = planRewriter.rewrite(node.getRight(), rightInputs);

            return new JoinNode(node.getId(), node.getType(), left, right, node.getCriteria());
        }
View Full Code Here

                    leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build());
                    rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
                    criteria = builder.build();
                }
                output = new JoinNode(node.getId(), node.getType(), leftSource, rightSource, criteria);
            }
            if (!postJoinPredicate.equals(BooleanLiteral.TRUE_LITERAL)) {
                output = new FilterNode(idAllocator.getNextId(), output, postJoinPredicate);
            }
            return output;
View Full Code Here

TOP

Related Classes of com.facebook.presto.sql.planner.plan.JoinNode$EquiJoinClause

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.