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

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


                if (!assignments.containsKey(canonical)) {
                    assignments.put(canonical, expression);
                }
            }

            return new ProjectNode(node.getId(), source, assignments);
        }
View Full Code Here


        {
            PlanNode source = planRewriter.rewrite(node.getSource(), context);

            if (node.getOutputSymbols().size() != source.getOutputSymbols().size()) {
                // Can't get rid of this projection. It constrains the output tuple from the underlying operator
                return new ProjectNode(node.getId(), source, node.getOutputMap());
            }

            boolean canElide = true;
            for (Map.Entry<Symbol, Expression> entry : node.getOutputMap().entrySet()) {
                Expression expression = entry.getValue();
                Symbol symbol = entry.getKey();
                if (!(expression instanceof QualifiedNameReference && ((QualifiedNameReference) expression).getName().equals(symbol.toQualifiedName()))) {
                    canElide = false;
                    break;
                }
            }

            if (canElide) {
                return source;
            }

            return new ProjectNode(node.getId(), source, node.getOutputMap());
        }
View Full Code Here

            Expression expression = node.getOutputMap().get(sampleWeightSymbol);
            if (expression instanceof QualifiedNameReference) {
                Symbol unaliasedSampleWeightSymbol = Symbol.fromQualifiedName(((QualifiedNameReference) expression).getName());
                context = new LimitContext(context.getCount(), Optional.of(unaliasedSampleWeightSymbol));
                PlanNode source = planRewriter.rewrite(node.getSource(), context);
                return new ProjectNode(node.getId(), source, node.getOutputMap());
            }
            else {
                // TODO: We might want to add another limit here that ignores sample weight, and push it down. We would have to assume that sample weight is never zero.
                PlanNode rewrittenNode = planRewriter.defaultRewrite(node, null);
                // Drop in a LimitNode b/c we cannot push our limit down any further
View Full Code Here

                }
            }

            PlanNode source = planRewriter.rewrite(node.getSource(), expectedInputs.build());

            return new ProjectNode(node.getId(), source, builder.build());
        }
View Full Code Here

                        rightProjections.put(rightSymbol, rightExpression);

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

                    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)) {
View Full Code Here

                for (Map.Entry<Symbol, Expression> projection : node.getOutputMap().entrySet()) {
                    Expression inlined = ExpressionTreeRewriter.rewriteWith(new ExpressionSymbolInliner(((ProjectNode) source).getOutputMap()), projection.getValue());
                    projections.put(projection.getKey(), inlined);
                }

                return new ProjectNode(node.getId(), ((ProjectNode) source).getSource(), projections.build());
            }

            return new ProjectNode(node.getId(), source, node.getOutputMap());
        }
View Full Code Here

        @Override
        public PlanNode rewriteProject(ProjectNode node, Void context, PlanRewriter<Void> planRewriter)
        {
            PlanNode source = planRewriter.rewrite(node.getSource(), context);
            Map<Symbol, Expression> assignments = ImmutableMap.copyOf(Maps.transformValues(node.getOutputMap(), canonicalizeExpressionFunction()));
            return new ProjectNode(node.getId(), source, assignments);
        }
View Full Code Here

    @Test
    public void testProject()
            throws Exception
    {
        PlanNode node = new ProjectNode(newId(),
                filter(baseTableScan,
                        and(
                                equals(AE, BE),
                                equals(BE, CE),
                                lessThan(CE, number(10)))),
View Full Code Here

                        rightProjections.put(rightSymbol, rightExpression);

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

                    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)) {
View Full Code Here

    @Test
    public void testProject()
            throws Exception
    {
        PlanNode node = new ProjectNode(newId(),
                filter(baseTableScan,
                        and(
                                equals(AE, BE),
                                equals(BE, CE),
                                lessThan(CE, number(10)))),
View Full Code Here

TOP

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

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.