prestodb/presto · warning · PrestoException

HIVE_PARTITION_DROPPED_DURING_QUERY

HIVE_PARTITION_DROPPED_DURING_QUERY

Error message

Statistics result does not contain entry for partition: ${partitionName}

What it means

updatePartitionStatistics re-reads current partition statistics and updates them; if a partition's statistics entry cannot be found (the partition was dropped concurrently or never had stats), it throws HIVE_PARTITION_DROPPED_DURING_QUERY. This signals the partition vanished between the query plan and the stats update.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/file/FileHiveMetastore.java:367

        Path tableMetadataDirectory = getTableMetadataDirectory(databaseName, tableName);
        TableMetadata tableMetadata = readSchemaFile("table", tableMetadataDirectory, tableCodec)
                .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));

        TableMetadata updatedMetadata = tableMetadata
                .withParameters(updateStatisticsParameters(tableMetadata.getParameters(), updatedStatistics.getBasicStatistics()))
                .withColumnStatistics(updatedStatistics.getColumnStatistics());

        writeSchemaFile("table", tableMetadataDirectory, tableCodec, updatedMetadata, true);
    }

    @Override
    public synchronized void updatePartitionStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, Map<String, Function<PartitionStatistics, PartitionStatistics>> updates)
    {
        updates.forEach((partitionName, update) -> {
            PartitionStatistics originalStatistics = getPartitionStatistics(metastoreContext, databaseName, tableName, ImmutableSet.of(partitionName)).get(partitionName);
            if (originalStatistics == null) {
                throw new PrestoException(HIVE_PARTITION_DROPPED_DURING_QUERY, "Statistics result does not contain entry for partition: " + partitionName);
            }
            PartitionStatistics updatedStatistics = update.apply(originalStatistics);

            Table table = getRequiredTable(metastoreContext, databaseName, tableName);
            List<String> partitionValues = extractPartitionValues(partitionName);
            Path partitionDirectory = getPartitionMetadataDirectory(table, partitionValues);
            PartitionMetadata partitionMetadata = readSchemaFile("partition", partitionDirectory, partitionCodec)
                    .orElseThrow(() -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), partitionValues));

            PartitionMetadata updatedMetadata = partitionMetadata
                    .withParameters(updateStatisticsParameters(partitionMetadata.getParameters(), updatedStatistics.getBasicStatistics()))
                    .withColumnStatistics(updatedStatistics.getColumnStatistics());

            writeSchemaFile("partition", partitionDirectory, partitionCodec, updatedMetadata, true);
        });
    }

    @Override

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Retry the operation; if the partition was intentionally dropped, the lost stats update can be ignored.
  2. Coordinate ETL jobs so partition drops don't race stats-updating queries (locks or scheduling).
  3. Verify the partition still exists (getPartitionNames/getPartition) before updating its statistics.

Example fix

// before
metastore.updatePartitionStatistics(metastoreContext, db, table, updateFunctions); // throws if partition gone
// after
Set<String> existing = metastore.getPartitionNames(metastoreContext, db, table)
        .orElse(ImmutableSet.of());
Map<String, Function<PartitionStatistics, PartitionStatistics>> live = updateFunctions.keySet().stream()
        .filter(existing::contains)
        .collect(toImmutableMap(fn -> fn, updateFunctions::get));
if (!live.isEmpty()) {
    metastore.updatePartitionStatistics(metastoreContext, db, table, live);
}
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> existing = metastore.getPartitionNames(metastoreContext, db, table).orElse(ImmutableSet.of());
// only include partitions still present in 'existing' in the update map

Try / catch

try {
    metastore.updatePartitionStatistics(metastoreContext, db, table, updates);
} catch (PrestoException e) {
    if (e.getErrorCode() == HIVE_PARTITION_DROPPED_DURING_QUERY.toErrorCode()) {
        // partition dropped concurrently: drop its update entry and retry for the rest
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling updatePartitionStatistics for a partitionName not returned by getPartitionStatistics — typically because another session dropped the partition (or table) while the query was running.

Common situations: Long-running INSERT/ANALYZE queries on partitions concurrently deleted by ETL cleanup; DROP PARTITION racing a query that computes stats; stale partition names after repartitioning.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/bbb21e6ec8bd16ab. Report an issue: GitHub.