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;
}
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);
}
}
}
Aggregations