use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class RuleAssert method formatPlan.
private String formatPlan(PlanNode plan, TypeProvider types) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, types);
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, session, types);
return inTransaction(session -> textLogicalPlan(translateExpressions(plan, types), types, metadata, StatsAndCosts.create(plan, statsProvider, costProvider), session, 2, false));
}
use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
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;
}
List<Symbol> aggregationsWithMask = aggregationNode.getAggregations().entrySet().stream().filter(entry -> entry.getValue().isDistinct()).map(entry -> entry.getKey()).collect(Collectors.toList());
if (aggregationsWithMask.size() != masks.keySet().size()) {
return NO_MATCH;
}
for (Symbol symbol : aggregationsWithMask) {
if (!masks.keySet().contains(symbol)) {
return NO_MATCH;
}
}
if (step != aggregationNode.getStep()) {
return NO_MATCH;
}
if (!matches(preGroupedSymbols, aggregationNode.getPreGroupedSymbols(), symbolAliases)) {
return NO_MATCH;
}
return match();
}
Aggregations