Search in sources :

Example 1 with GlueMetastoreStats

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

the class TestIcebergGlueCatalogAccessOperations method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    File tmp = Files.createTempDirectory("test_iceberg").toFile();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(testSession).build();
    AtomicReference<GlueMetastoreStats> catalogStatsReference = new AtomicReference<>();
    AtomicReference<GlueMetastoreStats> tableOperationStatsReference = new AtomicReference<>();
    queryRunner.installPlugin(new TestingIcebergPlugin(Optional.empty(), Optional.empty(), new StealStatsModule(catalogStatsReference, tableOperationStatsReference)));
    queryRunner.createCatalog("iceberg", "iceberg", ImmutableMap.of("iceberg.catalog.type", "glue", "hive.metastore.glue.default-warehouse-dir", tmp.getAbsolutePath()));
    queryRunner.execute("CREATE SCHEMA " + testSchema);
    catalogStats = verifyNotNull(catalogStatsReference.get(), "catalogStatsReference not set");
    tableOperationStats = verifyNotNull(tableOperationStatsReference.get(), "tableOperationStatsReference not set");
    return queryRunner;
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) GlueMetastoreStats(io.trino.plugin.hive.metastore.glue.GlueMetastoreStats) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File)

Example 2 with GlueMetastoreStats

use of io.trino.plugin.hive.metastore.glue.GlueMetastoreStats 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

GlueMetastoreStats (io.trino.plugin.hive.metastore.glue.GlueMetastoreStats)2 File (java.io.File)2 HdfsConfig (io.trino.plugin.hive.HdfsConfig)1 HdfsConfigurationInitializer (io.trino.plugin.hive.HdfsConfigurationInitializer)1 HdfsEnvironment (io.trino.plugin.hive.HdfsEnvironment)1 HiveHdfsConfiguration (io.trino.plugin.hive.HiveHdfsConfiguration)1 NoHdfsAuthentication (io.trino.plugin.hive.authentication.NoHdfsAuthentication)1 GlueHiveMetastoreConfig (io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig)1 TrinoCatalog (io.trino.plugin.iceberg.catalog.TrinoCatalog)1 GlueIcebergTableOperationsProvider (io.trino.plugin.iceberg.catalog.glue.GlueIcebergTableOperationsProvider)1 TrinoGlueCatalog (io.trino.plugin.iceberg.catalog.glue.TrinoGlueCatalog)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1 TrinoPrincipal (io.trino.spi.security.TrinoPrincipal)1 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.testng.annotations.Test)1