Search in sources :

Example 1 with HivePlugin

use of io.prestosql.plugin.hive.HivePlugin in project hetu-core by openlookeng.

the class HetuTestServer method addHiveCatalogToQueryRunner.

public void addHiveCatalogToQueryRunner(Map<String, String> hiveProperties) {
    queryRunner.installPlugin(new HivePlugin("hive"));
    queryRunner.createCatalog("hive", "hive", hiveProperties);
}
Also used : HivePlugin(io.prestosql.plugin.hive.HivePlugin)

Example 2 with HivePlugin

use of io.prestosql.plugin.hive.HivePlugin 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 3 with HivePlugin

use of io.prestosql.plugin.hive.HivePlugin in project hetu-core by openlookeng.

the class TestSpatialJoins method createQueryRunner.

private static DistributedQueryRunner createQueryRunner() throws Exception {
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().setSource(TestSpatialJoins.class.getSimpleName()).setCatalog("hive").setSchema("default").build(), 4);
    queryRunner.installPlugin(new GeoPlugin());
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();
    HiveConfig hiveConfig = new HiveConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hiveConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveConfig, new NoHdfsAuthentication());
    FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
    metastore.createDatabase(new HiveIdentity(SESSION), Database.builder().setDatabaseName("default").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
    queryRunner.installPlugin(new HivePlugin("hive", Optional.of(metastore)));
    queryRunner.createCatalog("hive", "hive");
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.prestosql.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) HiveHdfsConfiguration(io.prestosql.plugin.hive.HiveHdfsConfiguration) HivePlugin(io.prestosql.plugin.hive.HivePlugin) HdfsConfiguration(io.prestosql.plugin.hive.HdfsConfiguration) HiveHdfsConfiguration(io.prestosql.plugin.hive.HiveHdfsConfiguration) NoHdfsAuthentication(io.prestosql.plugin.hive.authentication.NoHdfsAuthentication) HiveIdentity(io.prestosql.plugin.hive.authentication.HiveIdentity) HiveConfig(io.prestosql.plugin.hive.HiveConfig) HdfsEnvironment(io.prestosql.plugin.hive.HdfsEnvironment) FileHiveMetastore(io.prestosql.plugin.hive.metastore.file.FileHiveMetastore) File(java.io.File)

Aggregations

HivePlugin (io.prestosql.plugin.hive.HivePlugin)3 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)2 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)2 File (java.io.File)2 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)1 HetuMetastorePlugin (io.hetu.core.metastore.HetuMetastorePlugin)1 Session (io.prestosql.Session)1 HdfsConfiguration (io.prestosql.plugin.hive.HdfsConfiguration)1 HdfsConfigurationInitializer (io.prestosql.plugin.hive.HdfsConfigurationInitializer)1 HdfsEnvironment (io.prestosql.plugin.hive.HdfsEnvironment)1 HiveConfig (io.prestosql.plugin.hive.HiveConfig)1 HiveHadoop2Plugin (io.prestosql.plugin.hive.HiveHadoop2Plugin)1 HiveHdfsConfiguration (io.prestosql.plugin.hive.HiveHdfsConfiguration)1 NoHdfsAuthentication (io.prestosql.plugin.hive.authentication.NoHdfsAuthentication)1 HiveMetastore (io.prestosql.plugin.hive.metastore.HiveMetastore)1 FileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore)1 FileHiveMetastore.createTestingFileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore)1