List of usage examples for com.amazonaws.services.glue.model UpdatePartitionRequest UpdatePartitionRequest
UpdatePartitionRequest
From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java
License:Apache License
@Override public void updatePartitionStatistics(String databaseName, String tableName, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) { PartitionStatistics currentStatistics = getPartitionStatistics(databaseName, tableName, ImmutableSet.of(partitionName)).get(partitionName); if (currentStatistics == null) { throw new PrestoException(HIVE_PARTITION_DROPPED_DURING_QUERY, "Statistics result does not contain entry for partition: " + partitionName); }/*from www . j a v a 2s . c o m*/ PartitionStatistics updatedStatistics = update.apply(currentStatistics); if (!updatedStatistics.getColumnStatistics().isEmpty()) { throw new PrestoException(NOT_SUPPORTED, "Glue metastore does not support column level statistics"); } List<String> partitionValues = toPartitionValues(partitionName); Partition partition = getPartition(databaseName, tableName, partitionValues) .orElseThrow(() -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), partitionValues)); try { PartitionInput partitionInput = GlueInputConverter.convertPartition(partition); partitionInput.setParameters( updateStatisticsParameters(partition.getParameters(), updatedStatistics.getBasicStatistics())); glueClient.updatePartition( new UpdatePartitionRequest().withDatabaseName(databaseName).withTableName(tableName) .withPartitionValueList(partition.getValues()).withPartitionInput(partitionInput)); } catch (EntityNotFoundException e) { throw new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), partitionValues); } 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 alterPartition(String databaseName, String tableName, PartitionWithStatistics partition) { try {/*from w ww.jav a 2 s. com*/ PartitionInput newPartition = GlueInputConverter.convertPartition(partition); glueClient.updatePartition(new UpdatePartitionRequest().withDatabaseName(databaseName) .withTableName(tableName).withPartitionInput(newPartition) .withPartitionValueList(partition.getPartition().getValues())); } catch (EntityNotFoundException e) { throw new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), partition.getPartition().getValues()); } catch (AmazonServiceException e) { throw new PrestoException(HIVE_METASTORE_ERROR, e); } }