use of io.trino.plugin.hive.metastore.Database in project trino by trinodb.
the class TestIcebergProjectionPushdownPlans method createLocalQueryRunner.
@Override
protected LocalQueryRunner createLocalQueryRunner() {
Session session = testSessionBuilder().setCatalog(CATALOG).setSchema(SCHEMA).build();
metastoreDir = Files.createTempDir();
HiveMetastore metastore = createTestingFileHiveMetastore(metastoreDir);
LocalQueryRunner queryRunner = LocalQueryRunner.create(session);
queryRunner.createCatalog(CATALOG, new TestingIcebergConnectorFactory(Optional.of(metastore), Optional.empty(), EMPTY_MODULE), ImmutableMap.of());
Database database = Database.builder().setDatabaseName(SCHEMA).setOwnerName(Optional.of("public")).setOwnerType(Optional.of(PrincipalType.ROLE)).build();
metastore.createDatabase(database);
return queryRunner;
}
use of io.trino.plugin.hive.metastore.Database in project trino by trinodb.
the class FileHiveMetastore method setDatabaseOwner.
@Override
public synchronized void setDatabaseOwner(String databaseName, HivePrincipal principal) {
Database database = getRequiredDatabase(databaseName);
Path databaseMetadataDirectory = getDatabaseMetadataDirectory(database.getDatabaseName());
Database newDatabase = Database.builder(database).setOwnerName(Optional.of(principal.getName())).setOwnerType(Optional.of(principal.getType())).build();
writeSchemaFile(DATABASE, databaseMetadataDirectory, databaseCodec, new DatabaseMetadata(currentVersion, newDatabase), true);
}
use of io.trino.plugin.hive.metastore.Database in project trino by trinodb.
the class TrinoHiveCatalog method defaultTableLocation.
@Override
public String defaultTableLocation(ConnectorSession session, SchemaTableName schemaTableName) {
Database database = metastore.getDatabase(schemaTableName.getSchemaName()).orElseThrow(() -> new SchemaNotFoundException(schemaTableName.getSchemaName()));
String tableNameForLocation = createNewTableName(schemaTableName.getTableName());
return getTableDefaultLocation(database, new HdfsEnvironment.HdfsContext(session), hdfsEnvironment, schemaTableName.getSchemaName(), tableNameForLocation).toString();
}
use of io.trino.plugin.hive.metastore.Database in project trino by trinodb.
the class TestConnectorPushdownRulesWithHive method createLocalQueryRunner.
@Override
protected Optional<LocalQueryRunner> createLocalQueryRunner() {
baseDir = Files.createTempDir();
HdfsConfig config = new HdfsConfig();
HdfsConfiguration configuration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config), ImmutableSet.of());
HdfsEnvironment environment = new HdfsEnvironment(configuration, config, new NoHdfsAuthentication());
metastore = new FileHiveMetastore(new NodeVersion("test_version"), environment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
Database database = Database.builder().setDatabaseName(SCHEMA_NAME).setOwnerName(Optional.of("public")).setOwnerType(Optional.of(PrincipalType.ROLE)).build();
metastore.createDatabase(database);
LocalQueryRunner queryRunner = LocalQueryRunner.create(HIVE_SESSION);
queryRunner.createCatalog(HIVE_CATALOG_NAME, new TestingHiveConnectorFactory(metastore), ImmutableMap.of());
return Optional.of(queryRunner);
}
use of io.trino.plugin.hive.metastore.Database in project trino by trinodb.
the class TestProtoUtils method testDatabaseNameLocation.
@Test
public void testDatabaseNameLocation() {
Database db = ProtoUtils.fromProto(TestingAlluxioMetastoreObjects.getTestingDatabase().build());
assertEquals(TestingAlluxioMetastoreObjects.DATABASE_NAME, db.getDatabaseName());
assertEquals("alluxio:///", db.getLocation().get());
// Intentionally leave location unset
alluxio.grpc.table.Database.Builder alluxioDb = TestingAlluxioMetastoreObjects.getTestingDatabase().clearLocation();
assertEquals(Optional.empty(), ProtoUtils.fromProto(alluxioDb.build()).getLocation());
}
Aggregations