Search in sources :

Example 1 with HiveHadoop2Plugin

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;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) FileHiveMetastore.createTestingFileHiveMetastore(io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore) HiveMetastore(io.prestosql.plugin.hive.metastore.HiveMetastore) HivePlugin(io.prestosql.plugin.hive.HivePlugin) HiveIdentity(io.prestosql.plugin.hive.authentication.HiveIdentity) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) File(java.io.File) Session(io.prestosql.Session)

Example 2 with HiveHadoop2Plugin

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");
    }
}
Also used : Module(com.google.inject.Module) Connection(java.sql.Connection) TestPrestoDriver.closeQuietly(io.prestosql.jdbc.TestPrestoDriver.closeQuietly) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ALL_NODES(io.prestosql.spi.connector.SystemTable.Distribution.ALL_NODES) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) InMemoryRecordSet(io.prestosql.spi.connector.InMemoryRecordSet) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) SQLException(java.sql.SQLException) ImmutableList(com.google.common.collect.ImmutableList) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) TableMetadataBuilder.tableMetadataBuilder(io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) ResultSet(java.sql.ResultSet) Map(java.util.Map) Logging(io.airlift.log.Logging) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) RecordCursor(io.prestosql.spi.connector.RecordCursor) Assert.assertFalse(org.testng.Assert.assertFalse) AfterClass(org.testng.annotations.AfterClass) ImmutableSet(com.google.common.collect.ImmutableSet) SystemTable(io.prestosql.spi.connector.SystemTable) ImmutableMap(com.google.common.collect.ImmutableMap) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) TupleDomain(io.prestosql.spi.predicate.TupleDomain) BeforeClass(org.testng.annotations.BeforeClass) Assert.fail(org.testng.Assert.fail) Set(java.util.Set) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) PreparedStatement(java.sql.PreparedStatement) Scopes(com.google.inject.Scopes) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) String.format(java.lang.String.format) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) Statement(java.sql.Statement) ConnectorTransactionHandle(io.prestosql.spi.connector.ConnectorTransactionHandle) Assert.assertTrue(org.testng.Assert.assertTrue) DriverManager(java.sql.DriverManager) Joiner(com.google.common.base.Joiner) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) Connection(java.sql.Connection) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) SystemTable(io.prestosql.spi.connector.SystemTable) Module(com.google.inject.Module) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

HiveHadoop2Plugin (io.prestosql.plugin.hive.HiveHadoop2Plugin)2 Joiner (com.google.common.base.Joiner)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Module (com.google.inject.Module)1 Scopes (com.google.inject.Scopes)1 Multibinder.newSetBinder (com.google.inject.multibindings.Multibinder.newSetBinder)1 Logging (io.airlift.log.Logging)1 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)1 HetuMetastorePlugin (io.hetu.core.metastore.HetuMetastorePlugin)1 Session (io.prestosql.Session)1 TestPrestoDriver.closeQuietly (io.prestosql.jdbc.TestPrestoDriver.closeQuietly)1 TableMetadataBuilder.tableMetadataBuilder (io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder)1 HivePlugin (io.prestosql.plugin.hive.HivePlugin)1 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)1 HiveMetastore (io.prestosql.plugin.hive.metastore.HiveMetastore)1 FileHiveMetastore.createTestingFileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore)1 TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)1 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)1