use of io.trino.sql.planner.assertions.MatchResult.NO_MATCH in project trino by trinodb.
the class DistinctLimitMatcher 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());
DistinctLimitNode distinctLimitNode = (DistinctLimitNode) node;
if (distinctLimitNode.getLimit() != limit) {
return NO_MATCH;
}
if (!distinctLimitNode.getHashSymbol().equals(hashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
return NO_MATCH;
}
return new MatchResult(ImmutableSet.copyOf(distinctLimitNode.getDistinctSymbols()).equals(distinctSymbols.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet())));
}
use of io.trino.sql.planner.assertions.MatchResult.NO_MATCH in project trino by trinodb.
the class IndexJoinMatcher 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());
IndexJoinNode indexJoinNode = (IndexJoinNode) node;
if (indexJoinNode.getCriteria().size() != criteria.size()) {
return NO_MATCH;
}
Set<IndexJoinNode.EquiJoinClause> actualCriteria = ImmutableSet.copyOf(indexJoinNode.getCriteria());
Set<IndexJoinNode.EquiJoinClause> expectedCriteria = criteria.stream().map(equiClause -> equiClause.getExpectedValue(symbolAliases)).collect(toImmutableSet());
if (!expectedCriteria.equals(actualCriteria)) {
return NO_MATCH;
}
if (!indexJoinNode.getProbeHashSymbol().equals(probeHashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
return NO_MATCH;
}
if (!indexJoinNode.getIndexHashSymbol().equals(indexHashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
return NO_MATCH;
}
return MatchResult.match();
}
use of io.trino.sql.planner.assertions.MatchResult.NO_MATCH in project trino by trinodb.
the class UnnestMatcher 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());
UnnestNode unnestNode = (UnnestNode) node;
if (unnestNode.getReplicateSymbols().size() != replicateSymbols.size()) {
return NO_MATCH;
}
if (!replicateSymbols.stream().map(symbolAliases::get).map(Symbol::from).collect(toImmutableList()).equals(unnestNode.getReplicateSymbols())) {
return NO_MATCH;
}
if (unnestNode.getMappings().size() != unnestMappings.size()) {
return NO_MATCH;
}
if (!IntStream.range(0, unnestMappings.size()).boxed().allMatch(index -> {
Mapping nodeMapping = unnestNode.getMappings().get(index);
PlanMatchPattern.UnnestMapping patternMapping = unnestMappings.get(index);
return nodeMapping.getInput().toSymbolReference().equals(symbolAliases.get(patternMapping.getInput())) && patternMapping.getOutputs().size() == nodeMapping.getOutputs().size();
})) {
return NO_MATCH;
}
if (ordinalitySymbol.isPresent() != unnestNode.getOrdinalitySymbol().isPresent()) {
return NO_MATCH;
}
if (!type.equals(unnestNode.getJoinType())) {
return NO_MATCH;
}
if (filter.isPresent() != unnestNode.getFilter().isPresent()) {
return NO_MATCH;
}
if (filter.isEmpty()) {
return MatchResult.match();
}
if (!new ExpressionVerifier(symbolAliases).process(unnestNode.getFilter().get(), filter.get())) {
return NO_MATCH;
}
return MatchResult.match();
}
use of io.trino.sql.planner.assertions.MatchResult.NO_MATCH in project trino by trinodb.
the class ValuesMatcher 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());
ValuesNode valuesNode = (ValuesNode) node;
if (expectedRows.isPresent()) {
if (expectedRows.get().size() != valuesNode.getRowCount()) {
return NO_MATCH;
}
if (outputSymbolAliases.size() > 0) {
if (!expectedRows.equals(valuesNode.getRows())) {
return NO_MATCH;
}
}
}
return match(SymbolAliases.builder().putAll(Maps.transformValues(outputSymbolAliases, index -> valuesNode.getOutputSymbols().get(index).toSymbolReference())).build());
}
use of io.trino.sql.planner.assertions.MatchResult.NO_MATCH in project trino by trinodb.
the class MarkDistinctMatcher 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());
MarkDistinctNode markDistinctNode = (MarkDistinctNode) node;
if (!markDistinctNode.getHashSymbol().equals(hashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
return NO_MATCH;
}
if (!ImmutableSet.copyOf(markDistinctNode.getDistinctSymbols()).equals(distinctSymbols.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet()))) {
return NO_MATCH;
}
return match(markerSymbol.toString(), markDistinctNode.getMarkerSymbol().toSymbolReference());
}
Aggregations