Search in sources :

Example 1 with LocalQueryRunner

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

the class LocalAtopQueryRunner method createQueryRunner.

public static LocalQueryRunner createQueryRunner(Map<String, String> catalogProperties, Class<? extends AtopFactory> factoryClass) throws Exception {
    Session session = testSessionBuilder().setCatalog("atop").setSchema("default").setTimeZoneKey(TimeZoneKey.getTimeZoneKey(TimeZone.getDefault().getID())).build();
    LocalQueryRunner queryRunner = new LocalQueryRunner(session);
    try {
        AtopConnectorFactory connectorFactory = new AtopConnectorFactory(factoryClass, LocalAtopQueryRunner.class.getClassLoader());
        ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder().putAll(catalogProperties).put("atop.max-history-days", "1");
        queryRunner.createCatalog("atop", connectorFactory, properties.build());
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) ImmutableMap(com.google.common.collect.ImmutableMap) Session(com.facebook.presto.Session)

Example 2 with LocalQueryRunner

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

the class StatisticsBenchmark method main.

public static void main(String... args) {
    LocalQueryRunner localQueryRunner = createLocalQueryRunner();
    new LongVarianceBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new LongVariancePopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new DoubleVarianceBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new DoubleVariancePopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new LongStdDevBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new LongStdDevPopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new DoubleStdDevBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
    new DoubleStdDevPopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults());
}
Also used : BenchmarkQueryRunner.createLocalQueryRunner(com.facebook.presto.benchmark.BenchmarkQueryRunner.createLocalQueryRunner) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner)

Example 3 with LocalQueryRunner

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

the class TestIterativeOptimizer method setUp.

@BeforeClass
public void setUp() {
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("local").setSchema("tiny").setSystemProperty("task_concurrency", "1").setSystemProperty("iterative_optimizer_enabled", "true").setSystemProperty("iterative_optimizer_timeout", "1ms");
    queryRunner = new LocalQueryRunner(sessionBuilder.build());
    queryRunner.createCatalog(queryRunner.getDefaultSession().getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with LocalQueryRunner

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

the class TestMergeWindows method assertUnitPlan.

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

Example 5 with LocalQueryRunner

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

the class TestLocalBinarySpilledQueries method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true").setSystemProperty(SystemSessionProperties.OPERATOR_MEMORY_LIMIT_BEFORE_SPILL, //spill constantly
    "1B").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());
    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)

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