Search in sources :

Example 1 with UpdateTableRequest

use of com.amazonaws.services.glue.model.UpdateTableRequest 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);
    }
}
Also used : TableInput(com.amazonaws.services.glue.model.TableInput) GlueInputConverter.toTableInput(com.facebook.presto.hive.metastore.glue.converter.GlueInputConverter.toTableInput) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) UpdateTableRequest(com.amazonaws.services.glue.model.UpdateTableRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) PrestoException(com.facebook.presto.spi.PrestoException) EntityNotFoundException(com.amazonaws.services.glue.model.EntityNotFoundException) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Example 2 with UpdateTableRequest

use of com.amazonaws.services.glue.model.UpdateTableRequest 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);
    }
}
Also used : TableInput(com.amazonaws.services.glue.model.TableInput) GlueInputConverter.toTableInput(com.facebook.presto.hive.metastore.glue.converter.GlueInputConverter.toTableInput) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) Table(com.facebook.presto.hive.metastore.Table) PartitionStatistics(com.facebook.presto.hive.metastore.PartitionStatistics) UpdateTableRequest(com.amazonaws.services.glue.model.UpdateTableRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) PrestoException(com.facebook.presto.spi.PrestoException) EntityNotFoundException(com.amazonaws.services.glue.model.EntityNotFoundException) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)2 EntityNotFoundException (com.amazonaws.services.glue.model.EntityNotFoundException)2 TableInput (com.amazonaws.services.glue.model.TableInput)2 UpdateTableRequest (com.amazonaws.services.glue.model.UpdateTableRequest)2 GlueInputConverter.toTableInput (com.facebook.presto.hive.metastore.glue.converter.GlueInputConverter.toTableInput)2 PrestoException (com.facebook.presto.spi.PrestoException)2 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)2 PartitionStatistics (com.facebook.presto.hive.metastore.PartitionStatistics)1 Table (com.facebook.presto.hive.metastore.Table)1