prestodb/presto · error · PrestoException
HIVE_CORRUPTED_COLUMN_STATISTICS
HIVE_CORRUPTED_COLUMN_STATISTICS
Error message
Corrupted partition statistics (Table: %s Partition: [%s] Column: %s): %s
What it means
A partition-level column statistic from the Hive metastore failed a sanity validation in MetastoreHiveStatisticsProvider.checkStatistics and is considered corrupted. Presto throws HIVE_CORRUPTED_COLUMN_STATISTICS naming table, partition, column and the violated invariant, refusing to use the bogus value for planning.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java:413
rowCount.getAsLong());
}
if (rowCount.isPresent() && trueCount.isPresent()) {
checkStatistics(
trueCount.getAsLong() <= rowCount.getAsLong(),
table,
partition,
column,
"booleanStatistics.trueCount must be less than or equal to rowCount. booleanStatistics.trueCount: %s. rowCount: %s.",
trueCount.getAsLong(),
rowCount.getAsLong());
}
});
}
private static void checkStatistics(boolean expression, SchemaTableName table, String partition, String column, String message, Object... args)
{
if (!expression) {
throw new PrestoException(
HIVE_CORRUPTED_COLUMN_STATISTICS,
format("Corrupted partition statistics (Table: %s Partition: [%s] Column: %s): %s", table, partition, column, format(message, args)));
}
}
private static void checkStatistics(boolean expression, SchemaTableName table, String partition, String message, Object... args)
{
if (!expression) {
throw new PrestoException(
HIVE_CORRUPTED_COLUMN_STATISTICS,
format("Corrupted partition statistics (Table: %s Partition: [%s]): %s", table, partition, format(message, args)));
}
}
private static TableStatistics getTableStatistics(
Map<String, ColumnHandle> columns,
Map<String, Type> columnTypes,
List<HivePartition> partitions,View on GitHub (pinned to 55bb57d202)
Solutions
- Recompute statistics: run ANALYZE on the table or drop and refresh partition stats
- Delete the offending column stats from the metastore for that partition
- Check for Hive/Presto version bugs affecting stat writing and upgrade
- Disable stats-dependent planning for that query/session as a workaround
Example fix
-- before: query fails on corrupted stats SELECT * FROM t WHERE p = '2024-01-01'; -- after: refresh stats then query ANALYZE TABLE t; SELECT * FROM t WHERE p = '2024-01-01';
Defensive patterns
Strategy: try-catch
Validate before calling
// sanity-check stats yourself before relying on them boolean sane = ndv >= 1 && min.compareTo(max) <= 0 && nullsCount <= rowCount && totalSize >= 0;
Try / catch
try {
return session.execute(query);
} catch (PrestoException e) {
if ("HIVE_CORRUPTED_COLUMN_STATISTICS".equals(e.getErrorCode().getName())) {
runAnalyze(table); // regenerate stats, then retry
return session.execute(query);
} throw e;
} Prevention
- Run ANALYZE regularly after bulk loads or schema changes
- Avoid writing stats with third-party tools that bypass Hive invariants
- Verify stats integrity after Hive/metastore version upgrades
- Check partition stats after failed compactions
When it happens
Trigger: Reading partition statistics (via validateColumnStatistics / getTableStatistics) where a column stat violates invariants — e.g. NDV less than 1, min > max, nulls count greater than row count, negative sizes.
Common situations: Stats corrupted by ANALYZE bugs or old Hive versions; stats written by third-party tools; manually edited metastore metadata; stats from a different column type after a schema change.
Related errors
- HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE
- HIVE_PARTITION_DROPPED_DURING_QUERY
- Table not found: ${databaseName}.${tableName}
- HIVE_INVALID_METADATA
- NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/26fcb90fdfd03ffe.
Report an issue: GitHub.