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

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


            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


                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());
                    for (Map.Entry<Symbol, Collection<Symbol>> entry : node.getSymbolMapping().asMap().entrySet()) {
                        Symbol inputSymbol = Iterables.get(entry.getValue(), i);
                        flattenedSymbolMap.putAll(entry.getKey(), rewrittenUnion.getSymbolMapping().get(inputSymbol));
                    }
                }
                else {
                    flattenedSources.add(rewrittenSource);
                    for (Map.Entry<Symbol, Collection<Symbol>> entry : node.getSymbolMapping().asMap().entrySet()) {
                        flattenedSymbolMap.put(entry.getKey(), Iterables.get(entry.getValue(), i));
                    }
                }
            }
            return new UnionNode(node.getId(), flattenedSources.build(), flattenedSymbolMap.build());
        }
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

                    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", Type.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", Type.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

                }
                builder.add(rewrittenSource);
            }

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

            return node;
        }
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

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.