Search in sources :

Example 6 with TpchPlugin

use of com.facebook.presto.tpch.TpchPlugin in project presto by prestodb.

the class HiveQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Iterable<TpchTable<?>> tables, Map<String, String> extraProperties, String security, Map<String, String> extraHiveProperties) throws Exception {
    assertEquals(DateTimeZone.getDefault(), TIME_ZONE, "Timezone not configured correctly. Add -Duser.timezone=Asia/Katmandu to your JVM arguments");
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4, extraProperties);
    try {
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();
        HiveClientConfig hiveClientConfig = new HiveClientConfig();
        HiveS3Config s3Config = new HiveS3Config();
        HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationUpdater(hiveClientConfig, s3Config));
        HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveClientConfig, new NoHdfsAuthentication());
        FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
        metastore.createDatabase(createDatabaseMetastoreObject(TPCH_SCHEMA));
        metastore.createDatabase(createDatabaseMetastoreObject(TPCH_BUCKETED_SCHEMA));
        queryRunner.installPlugin(new HivePlugin(HIVE_CATALOG, metastore));
        Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().putAll(extraHiveProperties).put("hive.metastore.uri", "thrift://localhost:8080").put("hive.time-zone", TIME_ZONE.getID()).put("hive.security", security).build();
        Map<String, String> hiveBucketedProperties = ImmutableMap.<String, String>builder().putAll(hiveProperties).put("hive.max-initial-split-size", // so that each bucket has multiple splits
        "10kB").put("hive.max-split-size", // so that each bucket has multiple splits
        "10kB").put("hive.storage-format", // so that there's no minimum split size for the file
        "TEXTFILE").put("hive.compression-codec", // so that the file is splittable
        "NONE").build();
        queryRunner.createCatalog(HIVE_CATALOG, HIVE_CATALOG, hiveProperties);
        queryRunner.createCatalog(HIVE_BUCKETED_CATALOG, HIVE_CATALOG, hiveBucketedProperties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        copyTpchTablesBucketed(queryRunner, "tpch", TINY_SCHEMA_NAME, createBucketedSession(), tables);
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) FileHiveMetastore(com.facebook.presto.hive.metastore.file.FileHiveMetastore) File(java.io.File)

Example 7 with TpchPlugin

use of com.facebook.presto.tpch.TpchPlugin in project presto by prestodb.

the class MySqlQueryRunner method createMySqlQueryRunner.

public static QueryRunner createMySqlQueryRunner(TestingMySqlServer server, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = new DistributedQueryRunner(createSession(), 3);
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        Map<String, String> properties = ImmutableMap.<String, String>builder().put("connection-url", server.getJdbcUrl()).put("allow-drop-table", "true").build();
        queryRunner.installPlugin(new MySqlPlugin());
        queryRunner.createCatalog("mysql", "mysql", properties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, server);
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Example 8 with TpchPlugin

use of com.facebook.presto.tpch.TpchPlugin in project presto by prestodb.

the class BlackHoleQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception {
    Session session = testSessionBuilder().setCatalog("blackhole").setSchema("default").build();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties);
    try {
        queryRunner.installPlugin(new BlackHolePlugin());
        queryRunner.createCatalog("blackhole", "blackhole", ImmutableMap.of());
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of());
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) Session(com.facebook.presto.Session)

Example 9 with TpchPlugin

use of com.facebook.presto.tpch.TpchPlugin in project presto by prestodb.

the class CassandraQueryRunner method createCassandraQueryRunner.

public static synchronized DistributedQueryRunner createCassandraQueryRunner() throws Exception {
    EmbeddedCassandra.start();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(createCassandraSession("tpch"), 4);
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    queryRunner.installPlugin(new CassandraPlugin());
    queryRunner.createCatalog("cassandra", "cassandra", ImmutableMap.of("cassandra.contact-points", EmbeddedCassandra.getHost(), "cassandra.native-protocol-port", Integer.toString(EmbeddedCassandra.getPort()), "cassandra.allow-drop-table", "true"));
    if (!tpchLoaded) {
        createKeyspace(EmbeddedCassandra.getSession(), "tpch");
        List<TpchTable<?>> tables = TpchTable.getTables();
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createCassandraSession("tpch"), tables);
        for (TpchTable table : tables) {
            EmbeddedCassandra.flush("tpch", table.getTableName());
        }
        EmbeddedCassandra.refreshSizeEstimates();
        tpchLoaded = true;
    }
    return queryRunner;
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TpchTable(io.airlift.tpch.TpchTable)

Example 10 with TpchPlugin

use of com.facebook.presto.tpch.TpchPlugin in project presto by prestodb.

the class JdbcQueryRunner method createJdbcQueryRunner.

public static DistributedQueryRunner createJdbcQueryRunner(Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = new DistributedQueryRunner(createSession(), 3);
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        Map<String, String> properties = TestingH2JdbcModule.createProperties();
        createSchema(properties, "tpch");
        queryRunner.installPlugin(new JdbcPlugin("base-jdbc", new TestingH2JdbcModule()));
        queryRunner.createCatalog("jdbc", "base-jdbc", properties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Aggregations

TpchPlugin (com.facebook.presto.tpch.TpchPlugin)20 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)17 Session (com.facebook.presto.Session)3 SqlParserOptions (com.facebook.presto.sql.parser.SqlParserOptions)3 File (java.io.File)3 BeforeClass (org.testng.annotations.BeforeClass)3 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 TestingPrestoClient (com.facebook.presto.tests.TestingPrestoClient)2 LexicoderRowSerializer (com.facebook.presto.accumulo.serializers.LexicoderRowSerializer)1 TestingEventListenerPlugin (com.facebook.presto.execution.TestEventListenerPlugin.TestingEventListenerPlugin)1 NoHdfsAuthentication (com.facebook.presto.hive.authentication.NoHdfsAuthentication)1 FileHiveMetastore (com.facebook.presto.hive.metastore.file.FileHiveMetastore)1 BlackHolePlugin (com.facebook.presto.plugin.blackhole.BlackHolePlugin)1 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)1 Plugin (com.facebook.presto.spi.Plugin)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 TpchTable (io.airlift.tpch.TpchTable)1 ExecutionException (java.util.concurrent.ExecutionException)1 Text (org.apache.hadoop.io.Text)1