use of com.amazonaws.services.glue.model.DatabaseInput in project presto by prestodb.
the class TestGlueInputConverter method testConvertDatabase.
@Test
public void testConvertDatabase() {
DatabaseInput dbInput = GlueInputConverter.convertDatabase(testDb);
assertEquals(dbInput.getName(), testDb.getDatabaseName());
assertEquals(dbInput.getDescription(), testDb.getComment().get());
assertEquals(dbInput.getLocationUri(), testDb.getLocation().get());
assertEquals(dbInput.getParameters(), testDb.getParameters());
}
use of com.amazonaws.services.glue.model.DatabaseInput in project presto by prestodb.
the class GlueInputConverter method convertDatabase.
public static DatabaseInput convertDatabase(Database database) {
DatabaseInput input = new DatabaseInput();
input.setName(database.getDatabaseName());
input.setParameters(database.getParameters());
database.getComment().ifPresent(input::setDescription);
database.getLocation().ifPresent(input::setLocationUri);
return input;
}
use of com.amazonaws.services.glue.model.DatabaseInput in project presto by prestodb.
the class GlueHiveMetastore method createDatabase.
@Override
public void createDatabase(MetastoreContext metastoreContext, Database database) {
if (!database.getLocation().isPresent() && defaultDir.isPresent()) {
String databaseLocation = new Path(defaultDir.get(), database.getDatabaseName()).toString();
database = Database.builder(database).setLocation(Optional.of(databaseLocation)).build();
}
try {
DatabaseInput databaseInput = GlueInputConverter.convertDatabase(database);
stats.getCreateDatabase().record(() -> glueClient.createDatabase(new CreateDatabaseRequest().withCatalogId(catalogId).withDatabaseInput(databaseInput)));
} catch (AlreadyExistsException e) {
throw new SchemaAlreadyExistsException(database.getDatabaseName());
} catch (AmazonServiceException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, e);
}
if (database.getLocation().isPresent()) {
createDirectory(hdfsContext, hdfsEnvironment, new Path(database.getLocation().get()));
}
}
use of com.amazonaws.services.glue.model.DatabaseInput in project presto by prestodb.
the class GlueHiveMetastore method renameDatabase.
@Override
public void renameDatabase(MetastoreContext metastoreContext, String databaseName, String newDatabaseName) {
try {
Database database = getDatabase(metastoreContext, databaseName).orElseThrow(() -> new SchemaNotFoundException(databaseName));
DatabaseInput renamedDatabase = GlueInputConverter.convertDatabase(database).withName(newDatabaseName);
stats.getUpdateDatabase().record(() -> glueClient.updateDatabase(new UpdateDatabaseRequest().withCatalogId(catalogId).withName(databaseName).withDatabaseInput(renamedDatabase)));
} catch (AmazonServiceException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, e);
}
}
Aggregations