use of io.prestosql.plugin.hive.HiveHadoop2Plugin in project hetu-core by openlookeng.
the class HindexQueryRunner method createQueryRunner.
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, Map<String, String> metastoreProperties, Map<String, String> coordinatorProperties) throws Exception {
Session session = testSessionBuilder().setSource("test").setCatalog("hive").setSchema("test").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).setExtraProperties(extraProperties).setCoordinatorProperties(coordinatorProperties).build();
try {
File tempDir = Files.createTempDirectory("test-hive").toFile();
File hiveDir = new File(tempDir, "hive_data");
HiveMetastore metastore = createTestingFileHiveMetastore(hiveDir);
HiveIdentity identity = new HiveIdentity(SESSION);
metastore.createDatabase(identity, Database.builder().setDatabaseName("test").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
queryRunner.installPlugin(new HetuFileSystemClientPlugin());
queryRunner.installPlugin(new HetuMetastorePlugin());
queryRunner.installPlugin(new HiveHadoop2Plugin());
queryRunner.installPlugin(new HeuristicIndexPlugin());
queryRunner.installPlugin(new HivePlugin("Hive", Optional.of(metastore)));
queryRunner.getServers().forEach(server -> {
try {
server.loadMetastore(metastoreProperties);
server.getHeuristicIndexerManager().buildIndexClient();
server.getHeuristicIndexerManager().initCache();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().put("hive.allow-drop-table", "true").build();
queryRunner.createCatalog("hive", "Hive", hiveProperties);
return queryRunner;
} catch (Exception e) {
queryRunner.close();
throw e;
}
}
use of io.prestosql.plugin.hive.HiveHadoop2Plugin in project hetu-core by openlookeng.
the class TestJdbcConnection method setupServer.
@BeforeClass
public void setupServer() throws Exception {
Logging.initialize();
Module systemTables = binder -> newSetBinder(binder, SystemTable.class).addBinding().to(ExtraCredentialsSystemTable.class).in(Scopes.SINGLETON);
server = new TestingPrestoServer(ImmutableList.of(systemTables));
server.installPlugin(new HiveHadoop2Plugin());
server.createCatalog("hive", "hive-hadoop2", ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toAbsolutePath().toString()).put("hive.security", "sql-standard").build());
try (Connection connection = createConnection();
Statement statement = connection.createStatement()) {
statement.execute("SET ROLE admin");
statement.execute("CREATE SCHEMA default");
statement.execute("CREATE SCHEMA fruit");
}
}
Aggregations