Search in sources :

Example 1 with RuleStatsRecorder

use of io.prestosql.sql.planner.RuleStatsRecorder in project hetu-core by openlookeng.

the class TestEliminateSorts method assertUnitPlan.

private void assertUnitPlan(@Language("SQL") String sql, PlanMatchPattern pattern) {
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(getQueryRunner().getMetadata()), new AddExchanges(getQueryRunner().getMetadata(), new TypeAnalyzer(new SqlParser(), getQueryRunner().getMetadata()), true), new PruneUnreferencedOutputs(), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getCostCalculator(), ImmutableSet.of(new RemoveRedundantIdentityProjections())));
    assertPlan(sql, pattern, optimizers);
}
Also used : RuleStatsRecorder(io.prestosql.sql.planner.RuleStatsRecorder) RemoveRedundantIdentityProjections(io.prestosql.sql.planner.iterative.rule.RemoveRedundantIdentityProjections) SqlParser(io.prestosql.sql.parser.SqlParser) IterativeOptimizer(io.prestosql.sql.planner.iterative.IterativeOptimizer) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer)

Example 2 with RuleStatsRecorder

use of io.prestosql.sql.planner.RuleStatsRecorder in project hetu-core by openlookeng.

the class TestOptimizeMixedDistinctAggregations method assertUnitPlan.

private void assertUnitPlan(String sql, PlanMatchPattern pattern) {
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(getQueryRunner().getMetadata()), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getEstimatedExchangesCostCalculator(), ImmutableSet.of(new RemoveRedundantIdentityProjections(), new SingleDistinctAggregationToGroupBy(), new MultipleDistinctAggregationToMarkDistinct())), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getEstimatedExchangesCostCalculator(), new TranslateExpressions(getQueryRunner().getMetadata(), getQueryRunner().getSqlParser()).rules(getMetadata())), new OptimizeMixedDistinctAggregations(getQueryRunner().getMetadata()), new PruneUnreferencedOutputs());
    assertPlan(sql, pattern, optimizers);
}
Also used : RuleStatsRecorder(io.prestosql.sql.planner.RuleStatsRecorder) RemoveRedundantIdentityProjections(io.prestosql.sql.planner.iterative.rule.RemoveRedundantIdentityProjections) MultipleDistinctAggregationToMarkDistinct(io.prestosql.sql.planner.iterative.rule.MultipleDistinctAggregationToMarkDistinct) IterativeOptimizer(io.prestosql.sql.planner.iterative.IterativeOptimizer) TranslateExpressions(io.prestosql.sql.planner.iterative.rule.TranslateExpressions) SingleDistinctAggregationToGroupBy(io.prestosql.sql.planner.iterative.rule.SingleDistinctAggregationToGroupBy)

Example 3 with RuleStatsRecorder

use of io.prestosql.sql.planner.RuleStatsRecorder in project hetu-core by openlookeng.

the class TestSetFlatteningOptimizer method assertPlan.

@Override
protected void assertPlan(String sql, PlanMatchPattern pattern) {
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(getQueryRunner().getMetadata()), new PruneUnreferencedOutputs(), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getEstimatedExchangesCostCalculator(), ImmutableSet.of(new RemoveRedundantIdentityProjections())), new SetFlatteningOptimizer());
    assertPlan(sql, pattern, optimizers);
}
Also used : RuleStatsRecorder(io.prestosql.sql.planner.RuleStatsRecorder) RemoveRedundantIdentityProjections(io.prestosql.sql.planner.iterative.rule.RemoveRedundantIdentityProjections) IterativeOptimizer(io.prestosql.sql.planner.iterative.IterativeOptimizer)

Example 4 with RuleStatsRecorder

use of io.prestosql.sql.planner.RuleStatsRecorder in project hetu-core by openlookeng.

the class BasePlanTest method assertMinimallyOptimizedPlan.

protected void assertMinimallyOptimizedPlan(@Language("SQL") String sql, PlanMatchPattern pattern) {
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(queryRunner.getMetadata()), new PruneUnreferencedOutputs(), new IterativeOptimizer(new RuleStatsRecorder(), queryRunner.getStatsCalculator(), queryRunner.getCostCalculator(), ImmutableSet.of(new RemoveRedundantIdentityProjections())));
    assertPlan(sql, LogicalPlanner.Stage.OPTIMIZED, pattern, optimizers);
}
Also used : PlanOptimizer(io.prestosql.sql.planner.optimizations.PlanOptimizer) RuleStatsRecorder(io.prestosql.sql.planner.RuleStatsRecorder) RemoveRedundantIdentityProjections(io.prestosql.sql.planner.iterative.rule.RemoveRedundantIdentityProjections) PruneUnreferencedOutputs(io.prestosql.sql.planner.optimizations.PruneUnreferencedOutputs) IterativeOptimizer(io.prestosql.sql.planner.iterative.IterativeOptimizer) UnaliasSymbolReferences(io.prestosql.sql.planner.optimizations.UnaliasSymbolReferences)

Example 5 with RuleStatsRecorder

use of io.prestosql.sql.planner.RuleStatsRecorder in project hetu-core by openlookeng.

the class TestIterativeOptimizer method optimizerTimeoutsOnNonConvergingPlan.

@Test(timeOut = 1000)
public void optimizerTimeoutsOnNonConvergingPlan() {
    PlanOptimizer optimizer = new IterativeOptimizer(new RuleStatsRecorder(), queryRunner.getStatsCalculator(), queryRunner.getCostCalculator(), ImmutableSet.of(new NonConvergingRule()));
    try {
        queryRunner.inTransaction(transactionSession -> {
            queryRunner.createPlan(transactionSession, "SELECT * FROM nation", ImmutableList.of(optimizer), WarningCollector.NOOP);
            fail("The optimizer should not converge");
            return null;
        });
    } catch (PrestoException ex) {
        assertEquals(ex.getErrorCode(), OPTIMIZER_TIMEOUT.toErrorCode());
    }
}
Also used : PlanOptimizer(io.prestosql.sql.planner.optimizations.PlanOptimizer) RuleStatsRecorder(io.prestosql.sql.planner.RuleStatsRecorder) PrestoException(io.prestosql.spi.PrestoException) Test(org.testng.annotations.Test)

Aggregations

RuleStatsRecorder (io.prestosql.sql.planner.RuleStatsRecorder)7 IterativeOptimizer (io.prestosql.sql.planner.iterative.IterativeOptimizer)6 RemoveRedundantIdentityProjections (io.prestosql.sql.planner.iterative.rule.RemoveRedundantIdentityProjections)6 TranslateExpressions (io.prestosql.sql.planner.iterative.rule.TranslateExpressions)3 TypeAnalyzer (io.prestosql.sql.planner.TypeAnalyzer)2 PlanOptimizer (io.prestosql.sql.planner.optimizations.PlanOptimizer)2 PrestoException (io.prestosql.spi.PrestoException)1 SqlParser (io.prestosql.sql.parser.SqlParser)1 GatherAndMergeWindows (io.prestosql.sql.planner.iterative.rule.GatherAndMergeWindows)1 MultipleDistinctAggregationToMarkDistinct (io.prestosql.sql.planner.iterative.rule.MultipleDistinctAggregationToMarkDistinct)1 SingleDistinctAggregationToGroupBy (io.prestosql.sql.planner.iterative.rule.SingleDistinctAggregationToGroupBy)1 PruneUnreferencedOutputs (io.prestosql.sql.planner.optimizations.PruneUnreferencedOutputs)1 UnaliasSymbolReferences (io.prestosql.sql.planner.optimizations.UnaliasSymbolReferences)1 Test (org.testng.annotations.Test)1