@Override public Void visitFilter(FilterNode node, ImmutableList.Builder<Expression> context) { context.add(node.getPredicate()); return super.visitFilter(node, context); }
@Override public Void visitFilter(FilterNode node, ImmutableList.Builder<Expression> context) { context.add(node.getPredicate()); return super.visitFilter(node, context); }
@Override public PlanNode visitFilter(FilterNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs = ImmutableSet.<Symbol>builder() .addAll(SymbolsExtractor.extractUnique(node.getPredicate())) .addAll(context.get()) .build(); PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new FilterNode(node.getId(), source, node.getPredicate()); }
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, FilterNode filterNode, Set<Symbol> referencedOutputs) { Set<Symbol> prunedFilterInputs = Streams.concat( referencedOutputs.stream(), SymbolsExtractor.extractUnique(filterNode.getPredicate()).stream()) .collect(toImmutableSet()); return restrictChildOutputs(idAllocator, filterNode, prunedFilterInputs); } }
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, FilterNode filterNode, Set<Symbol> referencedOutputs) { Set<Symbol> prunedFilterInputs = Streams.concat( referencedOutputs.stream(), SymbolsExtractor.extractUnique(filterNode.getPredicate()).stream()) .collect(toImmutableSet()); return restrictChildOutputs(idAllocator, filterNode, prunedFilterInputs); } }
@Override public JoinGraph visitFilter(FilterNode node, Context context) { JoinGraph graph = node.getSource().accept(this, context); return graph.withFilter(node.getPredicate()); }
@Override public Result apply(FilterNode filterNode, Captures captures, Context context) { Expression rewritten = rewriter.rewrite(filterNode.getPredicate(), context); if (filterNode.getPredicate().equals(rewritten)) { return Result.empty(); } return Result.ofPlanNode(new FilterNode(filterNode.getId(), filterNode.getSource(), rewritten)); } }
@Override public PhysicalOperation visitFilter(FilterNode node, LocalExecutionPlanContext context) { PlanNode sourceNode = node.getSource(); Expression filterExpression = node.getPredicate(); List<Symbol> outputSymbols = node.getOutputSymbols(); return visitScanFilterAndProject(context, node.getId(), sourceNode, Optional.of(filterExpression), Assignments.identity(outputSymbols), outputSymbols); }
@Override public Result apply(FilterNode filterNode, Captures captures, Context context) { Expression rewritten = rewriter.rewrite(filterNode.getPredicate(), context); if (filterNode.getPredicate().equals(rewritten)) { return Result.empty(); } return Result.ofPlanNode(new FilterNode(filterNode.getId(), filterNode.getSource(), rewritten)); } }
@Override public PhysicalOperation visitFilter(FilterNode node, LocalExecutionPlanContext context) { PlanNode sourceNode = node.getSource(); Expression filterExpression = node.getPredicate(); List<Symbol> outputSymbols = node.getOutputSymbols(); return visitScanFilterAndProject(context, node.getId(), sourceNode, Optional.of(filterExpression), Assignments.identity(outputSymbols), outputSymbols); }
@Override public Optional<PlanNodeStatsEstimate> doCalculate(FilterNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); PlanNodeStatsEstimate estimate = filterStatsCalculator.filterStats(sourceStats, node.getPredicate(), session, types); if (isDefaultFilterFactorEnabled(session) && estimate.isOutputRowCountUnknown()) { estimate = sourceStats.mapOutputRowCount(sourceRowCount -> sourceStats.getOutputRowCount() * UNKNOWN_FILTER_COEFFICIENT); } return Optional.of(estimate); } }
@Override public PlanNode visitFilter(FilterNode node, RewriteContext<Void> context) { PlanNode source = context.rewrite(node.getSource()); return new FilterNode(node.getId(), source, canonicalize(node.getPredicate())); }
@Override public Optional<PlanNodeStatsEstimate> doCalculate(FilterNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); PlanNodeStatsEstimate estimate = filterStatsCalculator.filterStats(sourceStats, node.getPredicate(), session, types); if (isDefaultFilterFactorEnabled(session) && estimate.isOutputRowCountUnknown()) { estimate = sourceStats.mapOutputRowCount(sourceRowCount -> sourceStats.getOutputRowCount() * UNKNOWN_FILTER_COEFFICIENT); } return Optional.of(estimate); } }
@Override public PlanWithProperties visitFilter(FilterNode node, PreferredProperties preferredProperties) { if (node.getSource() instanceof TableScanNode) { return planTableScan((TableScanNode) node.getSource(), node.getPredicate(), preferredProperties); } return rebaseAndDeriveProperties(node, planChild(node, preferredProperties)); }
@Override public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) { checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName()); FilterNode filterNode = (FilterNode) node; ExpressionVerifier verifier = new ExpressionVerifier(symbolAliases); return new MatchResult(verifier.process(filterNode.getPredicate(), predicate)); }
@Override public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) { checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName()); FilterNode filterNode = (FilterNode) node; ExpressionVerifier verifier = new ExpressionVerifier(symbolAliases); return new MatchResult(verifier.process(filterNode.getPredicate(), predicate)); }
@Override public Result apply(FilterNode filterNode, Captures captures, Context context) { TableScanNode tableScan = captures.get(TABLE_SCAN); PlanNode rewritten = planTableScan(tableScan, filterNode.getPredicate(), context.getSession(), context.getSymbolAllocator().getTypes(), context.getIdAllocator(), metadata, parser, domainTranslator); if (arePlansSame(filterNode, tableScan, rewritten)) { return Result.empty(); } return Result.ofPlanNode(rewritten); }
@Override public PlanNode visitFilter(FilterNode node, RewriteContext<Context> context) { if (node.getSource() instanceof TableScanNode) { return planTableScan((TableScanNode) node.getSource(), node.getPredicate(), context.get()); } return context.defaultRewrite(node, new Context(context.get().getLookupSymbols(), context.get().getSuccess())); }
@Override public Void visitFilter(FilterNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); // visit child Set<Symbol> inputs = createInputs(source, boundSymbols); checkDependencies(inputs, node.getOutputSymbols(), "Invalid node. Output symbols (%s) not in source plan output (%s)", node.getOutputSymbols(), node.getSource().getOutputSymbols()); Set<Symbol> dependencies = SymbolsExtractor.extractUnique(node.getPredicate()); checkDependencies(inputs, dependencies, "Invalid node. Predicate dependencies (%s) not in source plan output (%s)", dependencies, node.getSource().getOutputSymbols()); return null; }
@Override public PlanNode visitFilter(FilterNode node, RewriteContext<Context> context) { if (node.getSource() instanceof TableScanNode) { return planTableScan((TableScanNode) node.getSource(), node.getPredicate(), context.get()); } return context.defaultRewrite(node, new Context(context.get().getLookupSymbols(), context.get().getSuccess())); }