use of io.trino.cost.StatsProvider in project trino by trinodb.
the class WindowMatcher method detailMatches.
@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());
WindowNode windowNode = (WindowNode) node;
if (!prePartitionedInputs.map(expectedInputs -> expectedInputs.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet()).equals(windowNode.getPrePartitionedInputs())).orElse(true)) {
return NO_MATCH;
}
if (!specification.map(expectedSpecification -> expectedSpecification.getExpectedValue(symbolAliases).equals(windowNode.getSpecification())).orElse(true)) {
return NO_MATCH;
}
if (!preSortedOrderPrefix.map(Integer.valueOf(windowNode.getPreSortedOrderPrefix())::equals).orElse(true)) {
return NO_MATCH;
}
if (!hashSymbol.map(expectedHashSymbol -> expectedHashSymbol.map(alias -> alias.toSymbol(symbolAliases)).equals(windowNode.getHashSymbol())).orElse(true)) {
return NO_MATCH;
}
/*
* Window functions produce a symbol (the result of the function call) that we might
* want to bind to an alias so we can reference it further up the tree. As such,
* they need to be matched with an Alias matcher so we can bind the symbol if desired.
*/
return match();
}
use of io.trino.cost.StatsProvider in project trino by trinodb.
the class JoinMatcher method detailMatches.
@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());
JoinNode joinNode = (JoinNode) node;
if (joinNode.getCriteria().size() != equiCriteria.size()) {
return NO_MATCH;
}
if (filter.isPresent()) {
if (joinNode.getFilter().isEmpty()) {
return NO_MATCH;
}
if (!new ExpressionVerifier(symbolAliases).process(joinNode.getFilter().get(), filter.get())) {
return NO_MATCH;
}
} else {
if (joinNode.getFilter().isPresent()) {
return NO_MATCH;
}
}
if (distributionType.isPresent() && !distributionType.equals(joinNode.getDistributionType())) {
return NO_MATCH;
}
if (spillable.isPresent() && !spillable.equals(joinNode.isSpillable())) {
return NO_MATCH;
}
/*
* Have to use order-independent comparison; there are no guarantees what order
* the equi criteria will have after planning and optimizing.
*/
Set<JoinNode.EquiJoinClause> actual = ImmutableSet.copyOf(joinNode.getCriteria());
Set<JoinNode.EquiJoinClause> expected = equiCriteria.stream().map(maker -> maker.getExpectedValue(symbolAliases)).collect(toImmutableSet());
if (!expected.equals(actual)) {
return NO_MATCH;
}
return new MatchResult(matchDynamicFilters(joinNode, symbolAliases));
}
use of io.trino.cost.StatsProvider in project trino by trinodb.
the class TableExecuteMatcher method detailMatches.
@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());
TableExecuteNode tableExecuteNode = (TableExecuteNode) node;
if (!tableExecuteNode.getColumnNames().equals(columnNames)) {
return NO_MATCH;
}
if (!columns.stream().map(symbol -> Symbol.from(symbolAliases.get(symbol))).collect(toImmutableList()).equals(tableExecuteNode.getColumns())) {
return NO_MATCH;
}
return match();
}
use of io.trino.cost.StatsProvider in project trino by trinodb.
the class PlanAssert method assertPlan.
public static void assertPlan(Session session, Metadata metadata, FunctionManager functionManager, StatsCalculator statsCalculator, Plan actual, Lookup lookup, PlanMatchPattern pattern) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, actual.getTypes());
assertPlan(session, metadata, functionManager, statsProvider, actual, lookup, pattern);
}
use of io.trino.cost.StatsProvider in project trino by trinodb.
the class RowNumberMatcher method detailMatches.
@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());
RowNumberNode rowNumberNode = (RowNumberNode) node;
if (partitionBy.isPresent()) {
List<Symbol> expected = partitionBy.get().stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableList());
if (!expected.equals(rowNumberNode.getPartitionBy())) {
return NO_MATCH;
}
}
if (rowNumberSymbol.isPresent()) {
Symbol expected = rowNumberSymbol.get().toSymbol(symbolAliases);
if (!expected.equals(rowNumberNode.getRowNumberSymbol())) {
return NO_MATCH;
}
}
if (maxRowCountPerPartition.isPresent()) {
if (!maxRowCountPerPartition.get().equals(rowNumberNode.getMaxRowCountPerPartition())) {
return NO_MATCH;
}
}
if (hashSymbol.isPresent()) {
Optional<Symbol> expected = hashSymbol.get().map(alias -> alias.toSymbol(symbolAliases));
if (!expected.equals(rowNumberNode.getHashSymbol())) {
return NO_MATCH;
}
}
if (orderSensitive.isPresent()) {
if (!orderSensitive.get().equals(rowNumberNode.isOrderSensitive())) {
return NO_MATCH;
}
}
return match();
}
Aggregations