use of com.amazonaws.services.glue.model.CreateDatabaseRequest 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()));
}
}
Aggregations