Example usage for com.amazonaws.services.glue.model UpdateTableRequest UpdateTableRequest

List of usage examples for com.amazonaws.services.glue.model UpdateTableRequest UpdateTableRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model UpdateTableRequest UpdateTableRequest.

Prototype

UpdateTableRequest

Source Link

Usage

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public void updateTableStatistics(String databaseName, String tableName,
        Function<PartitionStatistics, PartitionStatistics> update) {
    PartitionStatistics currentStatistics = getTableStatistics(databaseName, tableName);
    PartitionStatistics updatedStatistics = update.apply(currentStatistics);
    if (!updatedStatistics.getColumnStatistics().isEmpty()) {
        throw new PrestoException(NOT_SUPPORTED, "Glue metastore does not support column level statistics");
    }//from w  w  w . j ava2s . c  o  m

    Table table = getTableOrElseThrow(databaseName, tableName);

    try {
        TableInput tableInput = GlueInputConverter.convertTable(table);
        tableInput.setParameters(
                updateStatisticsParameters(table.getParameters(), updatedStatistics.getBasicStatistics()));
        glueClient.updateTable(
                new UpdateTableRequest().withDatabaseName(databaseName).withTableInput(tableInput));
    } catch (EntityNotFoundException e) {
        throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public void replaceTable(String databaseName, String tableName, Table newTable,
        PrincipalPrivileges principalPrivileges) {
    try {//from w w w  . ja  va 2s . c om
        TableInput newTableInput = GlueInputConverter.convertTable(newTable);
        glueClient.updateTable(
                new UpdateTableRequest().withDatabaseName(databaseName).withTableInput(newTableInput));
    } catch (EntityNotFoundException e) {
        throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}