use of com.amazonaws.services.glue.model.AlreadyExistsException in project presto by prestodb.
the class GlueHiveMetastore method createTable.
@Override
public void createTable(MetastoreContext metastoreContext, Table table, PrincipalPrivileges principalPrivileges) {
try {
TableInput input = GlueInputConverter.convertTable(table);
stats.getCreateTable().record(() -> glueClient.createTable(new CreateTableRequest().withCatalogId(catalogId).withDatabaseName(table.getDatabaseName()).withTableInput(input)));
} catch (AlreadyExistsException e) {
throw new TableAlreadyExistsException(new SchemaTableName(table.getDatabaseName(), table.getTableName()));
} catch (EntityNotFoundException e) {
throw new SchemaNotFoundException(table.getDatabaseName());
} catch (AmazonServiceException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, e);
}
}
use of com.amazonaws.services.glue.model.AlreadyExistsException 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