Search in sources :

Example 1 with TestingHiveMetastore

use of com.facebook.presto.hive.metastore.TestingHiveMetastore in project presto by prestodb.

the class HiveBenchmarkQueryRunner method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner(File tempDir) {
    Session session = testSessionBuilder().setCatalog("hive").setSchema("tpch").build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    // add hive
    File hiveDir = new File(tempDir, "hive_data");
    TestingHiveMetastore metastore = new TestingHiveMetastore(hiveDir);
    metastore.createDatabase(Database.builder().setDatabaseName("tpch").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
    HiveConnectorFactory hiveConnectorFactory = new HiveConnectorFactory("hive", HiveBenchmarkQueryRunner.class.getClassLoader(), metastore);
    Map<String, String> hiveCatalogConfig = ImmutableMap.<String, String>builder().put("hive.metastore.uri", "thrift://none.invalid:0").put("hive.max-split-size", "10GB").build();
    localQueryRunner.createCatalog("hive", hiveConnectorFactory, hiveCatalogConfig);
    localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TestingHiveMetastore(com.facebook.presto.hive.metastore.TestingHiveMetastore) File(java.io.File) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Example 2 with TestingHiveMetastore

use of com.facebook.presto.hive.metastore.TestingHiveMetastore in project presto by prestodb.

the class TestHivePageSink method testAllFormats.

@Test
public void testAllFormats() throws Exception {
    HiveClientConfig config = new HiveClientConfig();
    File tempDir = Files.createTempDir();
    try {
        ExtendedHiveMetastore metastore = new TestingHiveMetastore(new File(tempDir, "metastore"));
        for (HiveStorageFormat format : HiveStorageFormat.values()) {
            config.setHiveStorageFormat(format);
            config.setHiveCompressionCodec(NONE);
            long uncompressedLength = writeTestFile(config, metastore, makeFileName(tempDir, config));
            assertGreaterThan(uncompressedLength, 0L);
            for (HiveCompressionCodec codec : HiveCompressionCodec.values()) {
                if (codec == NONE) {
                    continue;
                }
                config.setHiveCompressionCodec(codec);
                long length = writeTestFile(config, metastore, makeFileName(tempDir, config));
                assertTrue(uncompressedLength > length, format("%s with %s compressed to %s which is not less than %s", format, codec, length, uncompressedLength));
            }
        }
    } finally {
        FileUtils.deleteRecursively(tempDir);
    }
}
Also used : TestingHiveMetastore(com.facebook.presto.hive.metastore.TestingHiveMetastore) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

TestingHiveMetastore (com.facebook.presto.hive.metastore.TestingHiveMetastore)2 File (java.io.File)2 Session (com.facebook.presto.Session)1 ExtendedHiveMetastore (com.facebook.presto.hive.metastore.ExtendedHiveMetastore)1 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)1 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)1 Test (org.testng.annotations.Test)1