use of com.amazonaws.services.glue.model.TableInput 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.TableInput in project presto by prestodb.
the class GlueHiveMetastore method replaceTable.
@Override
public void replaceTable(MetastoreContext metastoreContext, String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges) {
try {
TableInput newTableInput = GlueInputConverter.convertTable(newTable);
stats.getUpdateTable().record(() -> glueClient.updateTable(new UpdateTableRequest().withCatalogId(catalogId).withDatabaseName(databaseName).withTableInput(newTableInput)));
} catch (EntityNotFoundException e) {
throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
} catch (AmazonServiceException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, e);
}
}
use of com.amazonaws.services.glue.model.TableInput in project presto by prestodb.
the class GlueHiveMetastore method updateTableStatistics.
@Override
public void updateTableStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, Function<PartitionStatistics, PartitionStatistics> update) {
PartitionStatistics currentStatistics = getTableStatistics(metastoreContext, databaseName, tableName);
PartitionStatistics updatedStatistics = update.apply(currentStatistics);
if (!updatedStatistics.getColumnStatistics().isEmpty()) {
throw new PrestoException(NOT_SUPPORTED, "Glue metastore does not support column level statistics");
}
Table table = getTableOrElseThrow(metastoreContext, databaseName, tableName);
try {
TableInput tableInput = GlueInputConverter.convertTable(table);
tableInput.setParameters(updateStatisticsParameters(table.getParameters(), updatedStatistics.getBasicStatistics()));
UpdateTableRequest request = new UpdateTableRequest().withCatalogId(catalogId).withDatabaseName(databaseName).withTableInput(tableInput);
stats.getUpdateTable().record(() -> glueClient.updateTable(request));
} catch (EntityNotFoundException e) {
throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
} catch (AmazonServiceException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, e);
}
}
use of com.amazonaws.services.glue.model.TableInput in project presto by prestodb.
the class GlueInputConverter method convertTable.
public static TableInput convertTable(Table table) {
TableInput input = new TableInput();
input.setName(table.getTableName());
input.setOwner(table.getOwner());
checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE, VIRTUAL_VIEW).contains(table.getTableType()), "Invalid table type: %s", table.getTableType());
input.setTableType(table.getTableType().toString());
input.setStorageDescriptor(convertStorage(table.getStorage(), table.getDataColumns()));
input.setPartitionKeys(table.getPartitionColumns().stream().map(GlueInputConverter::convertColumn).collect(toList()));
input.setParameters(table.getParameters());
table.getViewOriginalText().ifPresent(input::setViewOriginalText);
table.getViewExpandedText().ifPresent(input::setViewExpandedText);
return input;
}
use of com.amazonaws.services.glue.model.TableInput in project presto by prestodb.
the class GlueInputConverter method toTableInput.
public static TableInput toTableInput(com.amazonaws.services.glue.model.Table table) {
TableInput input = new TableInput();
input.setName(table.getName());
input.setOwner(table.getOwner());
input.setTableType(table.getTableType());
input.setStorageDescriptor(table.getStorageDescriptor());
input.setPartitionKeys(table.getPartitionKeys());
input.setParameters(table.getParameters());
input.setViewOriginalText(table.getViewOriginalText());
input.setViewExpandedText(table.getViewExpandedText());
return input;
}
Aggregations