prestodb/presto · error · PrestoException

HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE

HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE

Error message

Unknown column statistics type: 

What it means

When building HiveColumnStatistics for an empty partition, Statistics.createColumnStatisticsForEmptyPartition maps each recorded column statistic type (from the metastore) to a builder call. Unknown enum values hit the default branch and throw HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE, meaning the metastore returned a statistic type this Presto version does not understand.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/Statistics.java:277

                    break;
                case TOTAL_SIZE_IN_BYTES:
                    result.setTotalSizeInBytes(0);
                    break;
                case NUMBER_OF_DISTINCT_VALUES:
                    result.setDistinctValuesCount(0);
                    break;
                case NUMBER_OF_NON_NULL_VALUES:
                    result.setNullsCount(0);
                    break;
                case NUMBER_OF_TRUE_VALUES:
                    result.setBooleanStatistics(new BooleanStatistics(OptionalLong.of(0L), OptionalLong.of(0L)));
                    break;
                case MIN_VALUE:
                case MAX_VALUE:
                    setMinMaxForEmptyPartition(columnType, result);
                    break;
                default:
                    throw new PrestoException(HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE, "Unknown column statistics type: " + columnStatisticType.name());
            }
        }
        return result.build();
    }

    private static void setMinMaxForEmptyPartition(Type type, HiveColumnStatistics.Builder result)
    {
        if (type.equals(BIGINT) || type.equals(INTEGER) || type.equals(SMALLINT) || type.equals(TINYINT)) {
            result.setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty()));
        }
        else if (type.equals(DOUBLE) || type.equals(REAL)) {
            result.setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty()));
        }
        else if (type.equals(DATE)) {
            result.setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty()));
        }
        else if (type.equals(TIMESTAMP)) {
            result.setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty()));

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade Presto to a version that recognizes the statistic type in the metastore
  2. Drop and recompute statistics: call ANALYZE on the table after clearing stale stats from the metastore
  3. Remove the unknown statistic entries directly from the metastore (TAB_COL_STATS table)
  4. Pin all Presto nodes to the same version to avoid mixed-statistic writers

Example fix

// before: older Presto reading stats written by newer version
-- HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE: Unknown column statistics type: XYZ
// after: upgrade coordinator/workers to matching version, then
ANALYZE TABLE t COMPUTE STATISTICS;
Defensive patterns

Strategy: try-catch

Validate before calling

// Check metastore stats for unrecognized statistic types before ANALYZE/read
Set<String> known = Set.of("NUMBER_OF_DISTINCT_VALUES","MIN_VALUE","MAX_VALUE","NUMBER_OF_TRUE_VALUES", ...);
colStats.stream().filter(s -> !known.contains(s.getStatisticType())).forEach(s -> log.warn("unknown stat: " + s));

Try / catch

try {
    metastoreMetadata.getSessionProperty(...); // triggers stats read
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("HIVE_UNKNOWN_COLUMN_STATISTIC_TYPE")) {
        // purge TAB_COL_STATS rows for the table and rerun ANALYZE
    }
    throw e;
}

Prevention

When it happens

Trigger: Running ANALYZE or reading stats on a partition with no rows where columnStatistics encounters a ColumnStatisticType not handled by the switch (e.g. metadata written by a newer Presto/Hive version with additional statistic kinds).

Common situations: Mixed-version clusters where a newer coordinator wrote stats and an older metastore/reader reads them; stats left behind after a Presto downgrade; foreign tools writing metastore statistics.

Related errors


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