Search in sources :

Example 1 with GlueHiveMetastoreConfig

use of io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig in project trino by trinodb.

the class TestSharedGlueMetastore method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    Session icebergSession = testSessionBuilder().setCatalog(ICEBERG_CATALOG).setSchema(schema).build();
    Session hiveSession = testSessionBuilder().setCatalog(HIVE_CATALOG).setSchema(schema).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(icebergSession).build();
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    this.dataDirectory = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data");
    this.dataDirectory.toFile().deleteOnExit();
    queryRunner.installPlugin(new IcebergPlugin());
    queryRunner.createCatalog(ICEBERG_CATALOG, "iceberg", ImmutableMap.of("iceberg.catalog.type", "glue", "hive.metastore.glue.default-warehouse-dir", dataDirectory.toString()));
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of()), hdfsConfig, new NoHdfsAuthentication());
    this.glueMetastore = new GlueHiveMetastore(hdfsEnvironment, new GlueHiveMetastoreConfig(), directExecutor(), new DefaultGlueColumnStatisticsProviderFactory(new GlueHiveMetastoreConfig(), directExecutor(), directExecutor()), Optional.empty(), table -> true);
    queryRunner.installPlugin(new TestingHivePlugin(glueMetastore));
    queryRunner.createCatalog(HIVE_CATALOG, "hive");
    queryRunner.createCatalog("hive_with_redirections", "hive", ImmutableMap.of("hive.iceberg-catalog-name", "iceberg"));
    queryRunner.execute("CREATE SCHEMA " + schema + " WITH (location = '" + dataDirectory.toString() + "')");
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, icebergSession, ImmutableList.of(TpchTable.NATION));
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, hiveSession, ImmutableList.of(TpchTable.REGION));
    return queryRunner;
}
Also used : Logger(io.airlift.log.Logger) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) AbstractTestQueryFramework(io.trino.testing.AbstractTestQueryFramework) GlueHiveMetastoreConfig(io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) QueryAssertions.copyTpchTables(io.trino.testing.QueryAssertions.copyTpchTables) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) Path(java.nio.file.Path) TestTable.randomTableSuffix(io.trino.testing.sql.TestTable.randomTableSuffix) TpchTable(io.trino.tpch.TpchTable) AfterClass(org.testng.annotations.AfterClass) TINY_SCHEMA_NAME(io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME) ImmutableSet(com.google.common.collect.ImmutableSet) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) ImmutableMap(com.google.common.collect.ImmutableMap) String.format(java.lang.String.format) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) DefaultGlueColumnStatisticsProviderFactory(io.trino.plugin.hive.metastore.glue.DefaultGlueColumnStatisticsProviderFactory) ICEBERG_CATALOG(io.trino.plugin.iceberg.IcebergQueryRunner.ICEBERG_CATALOG) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) GlueHiveMetastore(io.trino.plugin.hive.metastore.glue.GlueHiveMetastore) HdfsConfig(io.trino.plugin.hive.HdfsConfig) QueryRunner(io.trino.testing.QueryRunner) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) TestingHivePlugin(io.trino.plugin.hive.TestingHivePlugin) Optional(java.util.Optional) Session(io.trino.Session) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) TestingHivePlugin(io.trino.plugin.hive.TestingHivePlugin) HdfsConfig(io.trino.plugin.hive.HdfsConfig) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) DefaultGlueColumnStatisticsProviderFactory(io.trino.plugin.hive.metastore.glue.DefaultGlueColumnStatisticsProviderFactory) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) GlueHiveMetastore(io.trino.plugin.hive.metastore.glue.GlueHiveMetastore) GlueHiveMetastoreConfig(io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig) Session(io.trino.Session)

Example 2 with GlueHiveMetastoreConfig

use of io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig in project trino by trinodb.

the class TestTrinoGlueCatalogTest method testDefaultLocation.

@Test
public void testDefaultLocation() throws IOException {
    Path tmpDirectory = Files.createTempDirectory("test_glue_catalog_default_location_");
    tmpDirectory.toFile().deleteOnExit();
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(new HiveHdfsConfiguration(new HdfsConfigurationInitializer(new HdfsConfig(), ImmutableSet.of()), ImmutableSet.of()), new HdfsConfig(), new NoHdfsAuthentication());
    TrinoCatalog catalogWithDefaultLocation = new TrinoGlueCatalog(hdfsEnvironment, new GlueIcebergTableOperationsProvider(new HdfsFileIoProvider(hdfsEnvironment), new GlueHiveMetastoreConfig()), AWSGlueAsyncClientBuilder.defaultClient(), new GlueMetastoreStats(), Optional.of(tmpDirectory.toAbsolutePath().toString()), false);
    String namespace = "test_default_location_" + randomTableSuffix();
    String table = "tableName";
    SchemaTableName schemaTableName = new SchemaTableName(namespace, table);
    catalogWithDefaultLocation.createNamespace(SESSION, namespace, ImmutableMap.of(), new TrinoPrincipal(PrincipalType.USER, SESSION.getUser()));
    try {
        File expectedSchemaDirectory = new File(tmpDirectory.toFile(), namespace + ".db");
        File expectedTableDirectory = new File(expectedSchemaDirectory, schemaTableName.getTableName());
        assertEquals(catalogWithDefaultLocation.defaultTableLocation(SESSION, schemaTableName), expectedTableDirectory.toPath().toAbsolutePath().toString());
    } finally {
        try {
            catalogWithDefaultLocation.dropNamespace(SESSION, namespace);
        } catch (Exception e) {
            LOG.warn("Failed to clean up namespace: %s", namespace);
        }
    }
}
Also used : Path(java.nio.file.Path) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) TrinoGlueCatalog(io.trino.plugin.iceberg.catalog.glue.TrinoGlueCatalog) HdfsConfig(io.trino.plugin.hive.HdfsConfig) GlueMetastoreStats(io.trino.plugin.hive.metastore.glue.GlueMetastoreStats) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) SchemaTableName(io.trino.spi.connector.SchemaTableName) TrinoCatalog(io.trino.plugin.iceberg.catalog.TrinoCatalog) IOException(java.io.IOException) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) GlueIcebergTableOperationsProvider(io.trino.plugin.iceberg.catalog.glue.GlueIcebergTableOperationsProvider) GlueHiveMetastoreConfig(io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

HdfsConfig (io.trino.plugin.hive.HdfsConfig)2 HdfsConfigurationInitializer (io.trino.plugin.hive.HdfsConfigurationInitializer)2 HdfsEnvironment (io.trino.plugin.hive.HdfsEnvironment)2 HiveHdfsConfiguration (io.trino.plugin.hive.HiveHdfsConfiguration)2 NoHdfsAuthentication (io.trino.plugin.hive.authentication.NoHdfsAuthentication)2 GlueHiveMetastoreConfig (io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig)2 Path (java.nio.file.Path)2 Test (org.testng.annotations.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 Logger (io.airlift.log.Logger)1 Session (io.trino.Session)1 TestingHivePlugin (io.trino.plugin.hive.TestingHivePlugin)1 HiveMetastore (io.trino.plugin.hive.metastore.HiveMetastore)1 DefaultGlueColumnStatisticsProviderFactory (io.trino.plugin.hive.metastore.glue.DefaultGlueColumnStatisticsProviderFactory)1 GlueHiveMetastore (io.trino.plugin.hive.metastore.glue.GlueHiveMetastore)1 GlueMetastoreStats (io.trino.plugin.hive.metastore.glue.GlueMetastoreStats)1 ICEBERG_CATALOG (io.trino.plugin.iceberg.IcebergQueryRunner.ICEBERG_CATALOG)1