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;
}
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);
}
}
Aggregations