Search in sources :

Example 1 with SqlParser

use of io.prestosql.sql.parser.SqlParser 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 SqlParser

use of io.prestosql.sql.parser.SqlParser 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 3 with SqlParser

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

use of io.prestosql.sql.parser.SqlParser 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)

Example 5 with SqlParser

use of io.prestosql.sql.parser.SqlParser in project hetu-core by openlookeng.

the class VerifyCommand method run.

public void run() {
    if (configFilename != null) {
        // Read
        System.setProperty("config", configFilename);
    }
    ImmutableList.Builder<Module> builder = ImmutableList.<Module>builder().add(new PrestoVerifierModule()).addAll(getAdditionalModules());
    Bootstrap app = new Bootstrap(builder.build());
    Injector injector;
    try {
        injector = app.strictConfig().initialize();
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
    try {
        VerifierConfig config = injector.getInstance(VerifierConfig.class);
        injector.injectMembers(this);
        Set<String> supportedEventClients = injector.getInstance(Key.get(new TypeLiteral<Set<String>>() {
        }, SupportedEventClients.class));
        for (String clientType : config.getEventClients()) {
            checkArgument(supportedEventClients.contains(clientType), "Unsupported event client: %s", clientType);
        }
        Set<EventClient> eventClients = injector.getInstance(Key.get(new TypeLiteral<Set<EventClient>>() {
        }));
        VerifierDao dao = Jdbi.create(getQueryDatabase(injector)).installPlugin(new SqlObjectPlugin()).onDemand(VerifierDao.class);
        ImmutableList.Builder<QueryPair> queriesBuilder = ImmutableList.builder();
        for (String suite : config.getSuites()) {
            queriesBuilder.addAll(dao.getQueriesBySuite(suite, config.getMaxQueries()));
        }
        List<QueryPair> queries = queriesBuilder.build();
        queries = applyOverrides(config, queries);
        queries = filterQueryTypes(new SqlParser(getParserOptions()), config, queries);
        queries = filterQueries(queries);
        if (config.getShadowWrites()) {
            Sets.SetView<QueryType> allowedTypes = Sets.union(config.getTestQueryTypes(), config.getControlQueryTypes());
            checkArgument(!Sets.intersection(allowedTypes, ImmutableSet.of(CREATE, MODIFY)).isEmpty(), "CREATE or MODIFY queries must be allowed in test or control to use write shadowing");
            queries = rewriteQueries(new SqlParser(getParserOptions()), config, queries);
        }
        // Load jdbc drivers if needed
        if (config.getAdditionalJdbcDriverPath() != null) {
            List<URL> urlList = getUrls(config.getAdditionalJdbcDriverPath());
            URL[] urls = new URL[urlList.size()];
            urlList.toArray(urls);
            if (config.getTestJdbcDriverName() != null) {
                loadJdbcDriver(urls, config.getTestJdbcDriverName());
            }
            if (config.getControlJdbcDriverName() != null) {
                loadJdbcDriver(urls, config.getControlJdbcDriverName());
            }
        }
        // TODO: construct this with Guice
        int numFailedQueries = new Verifier(System.out, config, eventClients).run(queries);
        System.exit((numFailedQueries > 0) ? 1 : 0);
    } catch (InterruptedException | MalformedURLException e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    } finally {
        try {
            injector.getInstance(LifeCycleManager.class).stop();
        } catch (Exception e) {
            throwIfUnchecked(e);
            throw new RuntimeException(e);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) SqlObjectPlugin(org.jdbi.v3.sqlobject.SqlObjectPlugin) URL(java.net.URL) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) Sets(com.google.common.collect.Sets) Bootstrap(io.airlift.bootstrap.Bootstrap) SqlParser(io.prestosql.sql.parser.SqlParser) UncheckedIOException(java.io.UncheckedIOException) SQLException(java.sql.SQLException) QueryRewriteException(io.prestosql.verifier.QueryRewriter.QueryRewriteException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) EventClient(io.airlift.event.client.EventClient) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Module(com.google.inject.Module)

Aggregations

SqlParser (io.prestosql.sql.parser.SqlParser)29 Expression (io.prestosql.sql.tree.Expression)11 ParsingOptions (io.prestosql.sql.parser.ParsingOptions)10 TypeAnalyzer (io.prestosql.sql.planner.TypeAnalyzer)6 Optional (java.util.Optional)6 BeforeClass (org.testng.annotations.BeforeClass)6 CubeFilter (io.hetu.core.spi.cube.CubeFilter)5 Metadata (io.prestosql.metadata.Metadata)5 Symbol (io.prestosql.spi.plan.Symbol)5 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)5 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)5 FunctionCall (io.prestosql.sql.tree.FunctionCall)5 List (java.util.List)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 Session (io.prestosql.Session)4 CubeManager (io.prestosql.cube.CubeManager)4 CallExpression (io.prestosql.spi.relation.CallExpression)4 VariableReferenceExpression (io.prestosql.spi.relation.VariableReferenceExpression)4 OriginalExpressionUtils.castToExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToExpression)4