Search in sources :

Example 1 with HivePlugin

use of com.facebook.presto.hive.HivePlugin in project presto by prestodb.

the class AbstractDeltaDistributedQueryTestBase method createDeltaQueryRunner.

private static DistributedQueryRunner createDeltaQueryRunner(Map<String, String> extraProperties) throws Exception {
    Session session = testSessionBuilder().setCatalog(DELTA_CATALOG).setSchema(DELTA_SCHEMA.toLowerCase(US)).setTimeZoneKey(UTC_KEY).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setExtraProperties(extraProperties).build();
    // Install the TPCH plugin for test data (not in Delta format)
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    Path dataDir = queryRunner.getCoordinator().getBaseDataDir().resolve("delta_metadata");
    Path catalogDir = dataDir.getParent().resolve("catalog");
    // Install a Delta connector catalog
    queryRunner.installPlugin(new DeltaPlugin());
    Map<String, String> deltaProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).build();
    queryRunner.createCatalog(DELTA_CATALOG, "delta", deltaProperties);
    // Install a Hive connector catalog that uses the same metastore as Delta
    // This catalog will be used to create tables in metastore as the Delta connector doesn't
    // support creating tables yet.
    queryRunner.installPlugin(new HivePlugin("hive"));
    Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).put("hive.allow-drop-table", "true").put("hive.security", "legacy").build();
    queryRunner.createCatalog(HIVE_CATALOG, "hive", hiveProperties);
    queryRunner.execute(format("CREATE SCHEMA %s.%s", HIVE_CATALOG, DELTA_SCHEMA));
    return queryRunner;
}
Also used : Path(java.nio.file.Path) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) HivePlugin(com.facebook.presto.hive.HivePlugin) Session(com.facebook.presto.Session)

Example 2 with HivePlugin

use of com.facebook.presto.hive.HivePlugin in project presto by prestodb.

the class TestSpatialJoins method createQueryRunner.

@Override
protected QueryRunner 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();
    HiveClientConfig hiveClientConfig = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hiveClientConfig, metastoreClientConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication());
    FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
    ColumnConverterProvider columnConverterProvider = HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER;
    metastore.createDatabase(new MetastoreContext("test_user", "test_queryId", Optional.empty(), Optional.empty(), Optional.empty(), false, columnConverterProvider), 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(com.facebook.presto.hive.HdfsConfigurationInitializer) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) HivePlugin(com.facebook.presto.hive.HivePlugin) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) HdfsConfiguration(com.facebook.presto.hive.HdfsConfiguration) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) HdfsEnvironment(com.facebook.presto.hive.HdfsEnvironment) FileHiveMetastore(com.facebook.presto.hive.metastore.file.FileHiveMetastore) File(java.io.File) HiveColumnConverterProvider(com.facebook.presto.hive.HiveColumnConverterProvider) ColumnConverterProvider(com.facebook.presto.hive.ColumnConverterProvider) HiveClientConfig(com.facebook.presto.hive.HiveClientConfig)

Example 3 with HivePlugin

use of com.facebook.presto.hive.HivePlugin in project presto by prestodb.

the class TestIcebergMetadataListing method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setIdentity(new Identity("hive", Optional.empty(), ImmutableMap.of("hive", new SelectedRole(ROLE, Optional.of("admin"))), ImmutableMap.of(), ImmutableMap.of())).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).build();
    Path catalogDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").resolve("catalog");
    queryRunner.installPlugin(new IcebergPlugin());
    Map<String, String> icebergProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).build();
    queryRunner.createCatalog(ICEBERG_CATALOG, "iceberg", icebergProperties);
    queryRunner.installPlugin(new HivePlugin("hive"));
    Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", catalogDir.toFile().toURI().toString()).put("hive.security", "sql-standard").build();
    queryRunner.createCatalog("hive", "hive", hiveProperties);
    return queryRunner;
}
Also used : Path(java.nio.file.Path) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) SelectedRole(com.facebook.presto.spi.security.SelectedRole) HivePlugin(com.facebook.presto.hive.HivePlugin) Identity(com.facebook.presto.spi.security.Identity) Session(com.facebook.presto.Session)

Aggregations

HivePlugin (com.facebook.presto.hive.HivePlugin)3 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 Session (com.facebook.presto.Session)2 Path (java.nio.file.Path)2 ColumnConverterProvider (com.facebook.presto.hive.ColumnConverterProvider)1 HdfsConfiguration (com.facebook.presto.hive.HdfsConfiguration)1 HdfsConfigurationInitializer (com.facebook.presto.hive.HdfsConfigurationInitializer)1 HdfsEnvironment (com.facebook.presto.hive.HdfsEnvironment)1 HiveClientConfig (com.facebook.presto.hive.HiveClientConfig)1 HiveColumnConverterProvider (com.facebook.presto.hive.HiveColumnConverterProvider)1 HiveHdfsConfiguration (com.facebook.presto.hive.HiveHdfsConfiguration)1 MetastoreClientConfig (com.facebook.presto.hive.MetastoreClientConfig)1 NoHdfsAuthentication (com.facebook.presto.hive.authentication.NoHdfsAuthentication)1 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)1 FileHiveMetastore (com.facebook.presto.hive.metastore.file.FileHiveMetastore)1 Identity (com.facebook.presto.spi.security.Identity)1 SelectedRole (com.facebook.presto.spi.security.SelectedRole)1 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)1 File (java.io.File)1