Search in sources :

Example 11 with LocalQueryRunner

use of com.facebook.presto.testing.LocalQueryRunner in project presto by prestodb.

the class TestQueryPlanDeterminism method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.<String, String>of());
    localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 12 with LocalQueryRunner

use of com.facebook.presto.testing.LocalQueryRunner in project presto by prestodb.

the class TestQueryPlansDeterministic method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Example 13 with LocalQueryRunner

use of com.facebook.presto.testing.LocalQueryRunner in project presto by prestodb.

the class TestLocalQueriesIndexed method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new IndexedTpchConnectorFactory(INDEX_SPEC, 1), ImmutableMap.of());
    return localQueryRunner;
}
Also used : IndexedTpchConnectorFactory(com.facebook.presto.tests.tpch.IndexedTpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Example 14 with LocalQueryRunner

use of com.facebook.presto.testing.LocalQueryRunner in project presto by prestodb.

the class TestMLQueries method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    MLPlugin plugin = new MLPlugin();
    for (Type type : plugin.getTypes()) {
        localQueryRunner.getTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        localQueryRunner.getTypeManager().addParametricType(parametricType);
    }
    localQueryRunner.getMetadata().addFunctions(extractFunctions(new MLPlugin().getFunctions()));
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) Type(com.facebook.presto.spi.type.Type) ParametricType(com.facebook.presto.spi.type.ParametricType) ParametricType(com.facebook.presto.spi.type.ParametricType) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Example 15 with LocalQueryRunner

use of com.facebook.presto.testing.LocalQueryRunner in project presto by prestodb.

the class BasePlanTest method assertMinimallyOptimizedPlan.

protected void assertMinimallyOptimizedPlan(@Language("SQL") String sql, PlanMatchPattern pattern) {
    LocalQueryRunner queryRunner = getQueryRunner();
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(), new PruneUnreferencedOutputs(), new PruneIdentityProjections());
    queryRunner.inTransaction(transactionSession -> {
        Plan actualPlan = queryRunner.createPlan(transactionSession, sql, optimizers, LogicalPlanner.Stage.OPTIMIZED);
        PlanAssert.assertPlan(transactionSession, queryRunner.getMetadata(), actualPlan, pattern);
        return null;
    });
}
Also used : PlanOptimizer(com.facebook.presto.sql.planner.optimizations.PlanOptimizer) PruneUnreferencedOutputs(com.facebook.presto.sql.planner.optimizations.PruneUnreferencedOutputs) PruneIdentityProjections(com.facebook.presto.sql.planner.optimizations.PruneIdentityProjections) Plan(com.facebook.presto.sql.planner.Plan) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) UnaliasSymbolReferences(com.facebook.presto.sql.planner.optimizations.UnaliasSymbolReferences)

Aggregations

LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)19 Session (com.facebook.presto.Session)13 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)11 ConnectorId (com.facebook.presto.connector.ConnectorId)3 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)3 Plan (com.facebook.presto.sql.planner.Plan)3 BenchmarkQueryRunner.createLocalQueryRunner (com.facebook.presto.benchmark.BenchmarkQueryRunner.createLocalQueryRunner)2 TestingSession.testSessionBuilder (com.facebook.presto.testing.TestingSession.testSessionBuilder)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 File (java.io.File)2 SessionBuilder (com.facebook.presto.Session.SessionBuilder)1 BenchmarkSuite (com.facebook.presto.benchmark.BenchmarkSuite)1 TestingHiveMetastore (com.facebook.presto.hive.metastore.TestingHiveMetastore)1 Driver (com.facebook.presto.operator.Driver)1 OperatorContext (com.facebook.presto.operator.OperatorContext)1 OutputFactory (com.facebook.presto.operator.OutputFactory)1 TaskContext (com.facebook.presto.operator.TaskContext)1 MemoryConnectorFactory (com.facebook.presto.plugin.memory.MemoryConnectorFactory)1 QueryId (com.facebook.presto.spi.QueryId)1 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)1