Search in sources :

Example 1 with TypeAnalyzer

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

the class TestExternalFunctionPushDownChecker method validatePlan.

private void validatePlan(PlanNode root) {
    getQueryRunner().inTransaction(session -> {
        // metadata.getCatalogHandle() registers the catalog for the transaction
        session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
        new ExternalFunctionPushDownChecker().validate(root, session, metadata, new TypeAnalyzer(new SqlParser(), metadata), TypeProvider.empty(), WarningCollector.NOOP);
        return null;
    });
}
Also used : SqlParser(io.prestosql.sql.parser.SqlParser) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer)

Example 2 with TypeAnalyzer

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

the class TestSimplifyExpressions method assertSimplifies.

private static void assertSimplifies(String expression, String expected) {
    Expression actualExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expression));
    Expression expectedExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expected));
    Expression rewritten = rewrite(actualExpression, TEST_SESSION, new PlanSymbolAllocator(booleanSymbolTypeMapFor(actualExpression)), METADATA, LITERAL_ENCODER, new TypeAnalyzer(SQL_PARSER, METADATA));
    assertEquals(normalize(rewritten), normalize(expectedExpression));
}
Also used : LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) ExpressionUtils.binaryExpression(io.prestosql.sql.ExpressionUtils.binaryExpression) Expression(io.prestosql.sql.tree.Expression) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer)

Example 3 with TypeAnalyzer

use of io.prestosql.sql.planner.TypeAnalyzer 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 4 with TypeAnalyzer

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

the class TestValidateAggregationsWithDefaultValues method validatePlan.

private void validatePlan(PlanNode root, boolean forceSingleNode) {
    getQueryRunner().inTransaction(session -> {
        // metadata.getCatalogHandle() registers the catalog for the transaction
        session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
        new ValidateAggregationsWithDefaultValues(forceSingleNode).validate(root, session, metadata, new TypeAnalyzer(new SqlParser(), metadata), TypeProvider.empty(), WarningCollector.NOOP);
        return null;
    });
}
Also used : SqlParser(io.prestosql.sql.parser.SqlParser) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer)

Example 5 with TypeAnalyzer

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

the class TestPushPredicateIntoTableScan method setUpBeforeClass.

@BeforeClass
public void setUpBeforeClass() {
    pushPredicateIntoTableScan = new PushPredicateIntoTableScan(tester().getMetadata(), new TypeAnalyzer(new SqlParser(), tester().getMetadata()), true);
    catalogName = tester().getCurrentConnectorId();
    TpchTableHandle nation = new TpchTableHandle("nation", 1.0);
    nationTableHandle = new TableHandle(catalogName, nation, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(nation, TupleDomain.all())));
    TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
    ordersTableHandle = new TableHandle(catalogName, orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
}
Also used : SqlParser(io.prestosql.sql.parser.SqlParser) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TypeAnalyzer (io.prestosql.sql.planner.TypeAnalyzer)21 Metadata (io.prestosql.metadata.Metadata)8 Type (io.prestosql.spi.type.Type)8 Symbol (io.prestosql.spi.plan.Symbol)7 Session (io.prestosql.Session)6 TableHandle (io.prestosql.spi.metadata.TableHandle)6 SqlParser (io.prestosql.sql.parser.SqlParser)6 List (java.util.List)6 Map (java.util.Map)6 Optional (java.util.Optional)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 RowExpression (io.prestosql.spi.relation.RowExpression)5 Rule (io.prestosql.sql.planner.iterative.Rule)5 Expression (io.prestosql.sql.tree.Expression)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Split (io.prestosql.metadata.Split)4 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)4 PlanNode (io.prestosql.spi.plan.PlanNode)4