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

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


                }
                builder.add(rewrittenSource);
            }

            if (modified) {
                return new UnionNode(node.getId(), builder.build(), node.getSymbolMapping());
            }

            return node;
        }
View Full Code Here


            if (createSingleNodePlan) {
                ImmutableList.Builder<PlanNode> sourceBuilder = ImmutableList.builder();
                for (PlanNode source : node.getSources()) {
                    sourceBuilder.add(source.accept(this, context).getRoot());
                }
                UnionNode unionNode = new UnionNode(node.getId(), sourceBuilder.build(), node.getSymbolMapping());
                return createSingleNodePlan(unionNode);
            }
            else {
                ImmutableList.Builder<SubPlan> sourceBuilder = ImmutableList.builder();
                ImmutableList.Builder<PlanFragmentId> fragmentIdBuilder = ImmutableList.builder();
View Full Code Here

    @Test
    public void testUnion()
            throws Exception
    {
        PlanNode node = new UnionNode(newId(),
                ImmutableList.<PlanNode>of(
                        filter(baseTableScan, greaterThan(AE, number(10))),
                        filter(baseTableScan, and(greaterThan(AE, number(10)), lessThan(AE, number(100)))),
                        filter(baseTableScan, and(greaterThan(AE, number(10)), lessThan(AE, number(100))))
                ),
View Full Code Here

            if (createSingleNodePlan) {
                ImmutableList.Builder<PlanNode> sourceBuilder = ImmutableList.builder();
                for (PlanNode source : node.getSources()) {
                    sourceBuilder.add(source.accept(this, context).getRoot());
                }
                UnionNode unionNode = new UnionNode(node.getId(), sourceBuilder.build(), node.getSymbolMapping());
                return createSingleNodePlan(unionNode);
            }
            else {
                ImmutableList.Builder<SubPlan> sourceBuilder = ImmutableList.builder();
                ImmutableList.Builder<PlanFragmentId> fragmentIdBuilder = ImmutableList.builder();
View Full Code Here

            }

            sources.add(relationPlan.getRoot());
        }

        PlanNode planNode = new UnionNode(idAllocator.getNextId(), sources.build(), symbolMapping.build());
        if (node.isDistinct()) {
            planNode = distinct(planNode);
        }
        return new RelationPlan(planNode, analysis.getOutputDescriptor(node), planNode.getOutputSymbols());
    }
View Full Code Here

                    return planRewriter.rewrite(input, null);
                }
            }).list();

            if (Iterables.all(rewrittenSources, not(instanceOf(MaterializeSampleNode.class)))) {
                return new UnionNode(node.getId(), rewrittenSources, node.getSymbolMapping());
            }

            // Add sample weight to any sources that don't have it, and pull MaterializeSample through the UNION
            ImmutableListMultimap.Builder<Symbol, Symbol> symbolMapping = ImmutableListMultimap.<Symbol, Symbol>builder().putAll(node.getSymbolMapping());
            ImmutableList.Builder<PlanNode> sources = ImmutableList.builder();
            Symbol outputSymbol = symbolAllocator.newSymbol("$sampleWeight", BIGINT);

            for (PlanNode source : rewrittenSources) {
                if (source instanceof MaterializeSampleNode) {
                    symbolMapping.put(outputSymbol, ((MaterializeSampleNode) source).getSampleWeightSymbol());
                    sources.add(((MaterializeSampleNode) source).getSource());
                }
                else {
                    Symbol symbol = symbolAllocator.newSymbol("$sampleWeight", BIGINT);
                    symbolMapping.put(outputSymbol, symbol);
                    sources.add(addSampleWeight(source, symbol));
                }
            }

            node = new UnionNode(node.getId(), sources.build(), symbolMapping.build());
            return new MaterializeSampleNode(idAllocator.getNextId(), node, outputSymbol);
        }
View Full Code Here

            ImmutableList.Builder<PlanNode> rewrittenSources = ImmutableList.builder();
            for (PlanNode source : node.getSources()) {
                rewrittenSources.add(planRewriter.rewrite(source, context));
            }

            return new UnionNode(node.getId(), rewrittenSources.build(), canonicalizeUnionSymbolMap(node.getSymbolMapping()));
        }
View Full Code Here

                    rewrittenContext = new LimitContext(context.getCount(), Optional.of(sampleWeights.get(i)));
                }
                sources.add(planRewriter.rewrite(node.getSources().get(i), rewrittenContext));
            }

            PlanNode output = new UnionNode(node.getId(), sources, node.getSymbolMapping());
            if (context != null) {
                output = new LimitNode(idAllocator.getNextId(), output, context.getCount(), context.getSampleWeight());
            }
            return output;
        }
View Full Code Here

                    expectedInputSymbols.add(Iterables.get(symbols, i));
                }
                rewrittenSubPlans.add(planRewriter.rewrite(node.getSources().get(i), expectedInputSymbols.build()));
            }

            return new UnionNode(node.getId(), rewrittenSubPlans.build(), rewrittenSymbolMapping);
        }
View Full Code Here

                }
                builder.add(rewrittenSource);
            }

            if (modified) {
                return new UnionNode(node.getId(), builder.build(), node.getSymbolMapping());
            }

            return node;
        }
View Full Code Here

TOP

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

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.