Search in sources :

Example 16 with StatsProvider

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));
}
Also used : CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) StatsProvider(io.prestosql.cost.StatsProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider) CostProvider(io.prestosql.cost.CostProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider)

Example 17 with StatsProvider

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();
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) Step(io.prestosql.spi.plan.AggregationNode.Step) StatsProvider(io.prestosql.cost.StatsProvider) Collection(java.util.Collection) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) MatchResult.match(io.prestosql.sql.planner.assertions.MatchResult.match) PlanNode(io.prestosql.spi.plan.PlanNode) Collectors(java.util.stream.Collectors) Metadata(io.prestosql.metadata.Metadata) Preconditions.checkState(com.google.common.base.Preconditions.checkState) AggregationNode(io.prestosql.spi.plan.AggregationNode) List(java.util.List) Map(java.util.Map) Session(io.prestosql.Session) Optional(java.util.Optional) NO_MATCH(io.prestosql.sql.planner.assertions.MatchResult.NO_MATCH) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) Symbol(io.prestosql.spi.plan.Symbol) AggregationNode(io.prestosql.spi.plan.AggregationNode)

Aggregations

StatsProvider (io.prestosql.cost.StatsProvider)17 PlanNode (io.prestosql.spi.plan.PlanNode)11 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)8 Preconditions.checkState (com.google.common.base.Preconditions.checkState)8 Session (io.prestosql.Session)8 Metadata (io.prestosql.metadata.Metadata)8 NO_MATCH (io.prestosql.sql.planner.assertions.MatchResult.NO_MATCH)8 List (java.util.List)8 CachingStatsProvider (io.prestosql.cost.CachingStatsProvider)7 MatchResult.match (io.prestosql.sql.planner.assertions.MatchResult.match)7 Optional (java.util.Optional)7 CachingCostProvider (io.prestosql.cost.CachingCostProvider)6 CostProvider (io.prestosql.cost.CostProvider)6 Objects.requireNonNull (java.util.Objects.requireNonNull)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)5 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)3 Symbol (io.prestosql.spi.plan.Symbol)3 SymbolUtils.toSymbolReference (io.prestosql.sql.planner.SymbolUtils.toSymbolReference)3 TypeProvider (io.prestosql.sql.planner.TypeProvider)3 Map (java.util.Map)3