MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) { SymbolAliases.Builder newAliases = SymbolAliases.builder(); for (Matcher matcher : matchers) { MatchResult matchResult = matcher.detailMatches(node, stats, session, metadata, symbolAliases); if (!matchResult.isMatch()) { return NO_MATCH; } newAliases.putAll(matchResult.getAliases()); } return match(newAliases.build()); }
public static PlanMatchPattern constrainedTableScanWithTableLayout(String expectedTableName, Map<String, Domain> constraint, Map<String, String> columnReferences) { PlanMatchPattern result = TableScanMatcher.builder(expectedTableName) .expectedConstraint(constraint) .hasTableLayout() .build(); return result.addColumnReferences(expectedTableName, columnReferences); }
public static PlanMatchPattern constrainedTableScan(String expectedTableName, Map<String, Domain> constraint) { return TableScanMatcher.builder(expectedTableName) .expectedConstraint(constraint) .build(); }
public static PlanMatchPattern markDistinct( String markerSymbol, List<String> distinctSymbols, PlanMatchPattern source) { return node(MarkDistinctNode.class, source).with(new MarkDistinctMatcher( new SymbolAlias(markerSymbol), toSymbolAliases(distinctSymbols), Optional.empty())); }
public static MatchResult match(String alias, SymbolReference symbolReference) { SymbolAliases newAliases = SymbolAliases.builder() .put(alias, symbolReference) .build(); return new MatchResult(true, newAliases); }
public static PlanMatchPattern constrainedIndexSource(String expectedTableName, Map<String, Domain> constraint, Map<String, String> columnReferences) { return node(IndexSourceNode.class) .with(new IndexSourceMatcher(expectedTableName, constraint)) .addColumnReferences(expectedTableName, columnReferences); }
public SymbolAliases updateAssignments(Assignments assignments) { return builder() .putAll(this) .putUnchecked(getUpdatedAssignments(assignments)) .build(); }
public static PlanMatchPattern exchange(ExchangeNode.Scope scope, ExchangeNode.Type type, List<Ordering> orderBy, PlanMatchPattern... sources) { return node(ExchangeNode.class, sources) .with(new ExchangeMatcher(scope, type, orderBy)); }
PlanMatchPattern build() { PlanMatchPattern result = node(TableScanNode.class).with( new TableScanMatcher( expectedTableName, expectedConstraint, hasTableLayout)); return result; } }
public static PlanMatchPattern sort(List<Ordering> orderBy, PlanMatchPattern source) { return node(SortNode.class, source) .with(new SortMatcher(orderBy)); }
public static PlanMatchPattern lateral(List<String> correlationSymbolAliases, PlanMatchPattern inputPattern, PlanMatchPattern subqueryPattern) { return node(LateralJoinNode.class, inputPattern, subqueryPattern) .with(new CorrelationMatcher(correlationSymbolAliases)); }
public static PlanMatchPattern assignUniqueId(String uniqueSymbolAlias, PlanMatchPattern source) { return node(AssignUniqueId.class, source) .withAlias(uniqueSymbolAlias, new AssignUniqueIdMatcher()); }
private static PlanMatchPattern values( Map<String, Integer> aliasToIndex, Optional<Integer> expectedOutputSymbolCount, Optional<List<List<Expression>>> expectedRows) { return node(ValuesNode.class).with(new ValuesMatcher(aliasToIndex, expectedOutputSymbolCount, expectedRows)); }
PlanMatchPattern build() { return node(TopNRowNumberNode.class, source).with( new TopNRowNumberMatcher( specification, rowNumberSymbol, maxRowCountPerPartition, partial, hashSymbol)); } }
PlanMatchPattern build() { return node(RowNumberNode.class, source).with( new RowNumberMatcher( partitionBy, maxRowCountPerPartition, rowNumberSymbol, hashSymbol)); } }
public static PlanMatchPattern filter(Expression expectedPredicate, PlanMatchPattern source) { return node(FilterNode.class, source).with(new FilterMatcher(expectedPredicate)); }
public Builder specification( List<String> partitionBy, List<String> orderBy, Map<String, SortOrder> orderings) { return specification(PlanMatchPattern.specification(partitionBy, orderBy, orderings)); }
public static ExpectedValueProvider<JoinNode.EquiJoinClause> equiJoinClause(String left, String right) { return new EquiJoinClauseProvider(new SymbolAlias(left), new SymbolAlias(right)); }
public static MatchResult match() { return new MatchResult(true, new SymbolAliases()); }