use of io.trino.sql.planner.plan.AggregationNode.Step in project trino by trinodb.
the class AggregationMatcher 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());
AggregationNode aggregationNode = (AggregationNode) node;
if (groupId.isPresent() != aggregationNode.getGroupIdSymbol().isPresent()) {
return NO_MATCH;
}
if (!matches(groupingSets.getGroupingKeys(), aggregationNode.getGroupingKeys(), symbolAliases)) {
return NO_MATCH;
}
if (groupingSets.getGroupingSetCount() != aggregationNode.getGroupingSetCount()) {
return NO_MATCH;
}
if (!groupingSets.getGlobalGroupingSets().equals(aggregationNode.getGlobalGroupingSets())) {
return NO_MATCH;
}
Set<Symbol> actualMasks = aggregationNode.getAggregations().values().stream().filter(aggregation -> aggregation.getMask().isPresent()).map(aggregation -> aggregation.getMask().get()).collect(toImmutableSet());
Set<Symbol> expectedMasks = masks.stream().map(name -> new Symbol(symbolAliases.get(name).getName())).collect(toImmutableSet());
if (!actualMasks.equals(expectedMasks)) {
return NO_MATCH;
}
if (step != aggregationNode.getStep()) {
return NO_MATCH;
}
if (!matches(preGroupedSymbols, aggregationNode.getPreGroupedSymbols(), symbolAliases)) {
return NO_MATCH;
}
if (!preGroupedSymbols.isEmpty() && !aggregationNode.isStreamable()) {
return NO_MATCH;
}
return match();
}
Aggregations