Source:
<code>public synchronized void updatePartitionStatistics(String databaseName, String tableName, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) { PartitionStatistics currentStatistics = requireNonNull( getPartitionStatistics(databaseName, tableName, ImmutableSet.of(partitionName)).get(partitionName), "getPartitionStatistics() returned null"); PartitionStatistics updatedStatistics = update.apply(currentStatistics); List<Partition> partitions = getPartitionsByNames(databaseName, tableName, ImmutableList.of(partitionName)); if (partitions.size() != 1) { <START> throw new PrestoException(HIVE_METASTORE_ERROR, "exactly one partition is expected to be returned: " + partitions.size()); <END> } Partition originalPartition = getOnlyElement(partitions); Partition modifiedPartition = originalPartition.deepCopy(); modifiedPartition.setParameters(updateStatisticParameters(modifiedPartition.getParameters(), updatedStatistics.getBasicStatistics())); alterPartition(databaseName, tableName, modifiedPartition); com.facebook.presto.hive.metastore.Table table = getTable(databaseName, tableName) .map(ThriftMetastoreUtil::fromMetastoreApiTable) .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName))); List<ColumnStatisticsObj> metastoreColumnStatistics = updatedStatistics.getColumnStatistics().entrySet() .stream() .map(entry -> createMetastoreColumnStatistics(entry.getKey(), table.getColumn(entry.getKey()).get().getType(), entry.getValue())) .collect(toImmutableList()); if (!metastoreColumnStatistics.isEmpty()) { setPartitionColumnStatistics(databaseName, tableName, partitionName, metastoreColumnStatistics); } Set<String> removedStatistics = difference(currentStatistics.getColumnStatistics().keySet(), updatedStatistics.getColumnStatistics().keySet()); removedStatistics.forEach(column -> deletePartitionColumnStatistics(databaseName, tableName, partitionName, column)); }</code><technical_language>this java "Metastore returned multiple partitions for name: " + partitionName</technical_language>

Target:
public synchronized void updatePartitionStatistics(String databaseName, String tableName, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) { PartitionStatistics currentStatistics = requireNonNull( getPartitionStatistics(databaseName, tableName, ImmutableSet.of(partitionName)).get(partitionName), "getPartitionStatistics() returned null"); PartitionStatistics updatedStatistics = update.apply(currentStatistics); List<Partition> partitions = getPartitionsByNames(databaseName, tableName, ImmutableList.of(partitionName)); if (partitions.size() != 1) { throw new PrestoException(HIVE_METASTORE_ERROR, "Metastore returned multiple partitions for name: " + partitionName); } Partition originalPartition = getOnlyElement(partitions); Partition modifiedPartition = originalPartition.deepCopy(); modifiedPartition.setParameters(updateStatisticsParameters(modifiedPartition.getParameters(), updatedStatistics.getBasicStatistics())); alterPartition(databaseName, tableName, modifiedPartition); com.facebook.presto.hive.metastore.Table table = getTable(databaseName, tableName) .map(ThriftMetastoreUtil::fromMetastoreApiTable) .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName))); List<ColumnStatisticsObj> metastoreColumnStatistics = updatedStatistics.getColumnStatistics().entrySet().stream() .map(entry -> createMetastoreColumnStatistics(entry.getKey(), table.getColumn(entry.getKey()).get().getType(), entry.getValue())) .collect(toImmutableList()); if (!metastoreColumnStatistics.isEmpty()) { setPartitionColumnStatistics(databaseName, tableName, partitionName, metastoreColumnStatistics); } Set<String> removedStatistics = difference(currentStatistics.getColumnStatistics().keySet(), updatedStatistics.getColumnStatistics().keySet()); removedStatistics.forEach(column -> deletePartitionColumnStatistics(databaseName, tableName, partitionName, column)); }