prestodb/presto · error · PrestoException

HIVE_INVALID_METADATA

HIVE_INVALID_METADATA

Error message

Invalid column statistics data: + glueStatsData

What it means

fromGlueColumnStatistics converts Glue's ColumnStatisticsData into Presto's HiveColumnStatistics. When the statistics data type is UNKNOWN_TO_SDK_VERSION (the SDK received a newer type than it knows), and as a final fallthrough, it throws HIVE_INVALID_METADATA because the statistics cannot be interpreted.

Source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueStatisticsConverter.java:281

                        min,
                        max,
                        nullsCount,
                        fromMetastoreDistinctValuesCount(distinctValues, nullsCount, rowCount));
            }
            case STRING: {
                StringColumnStatisticsData data = glueStatsData.stringColumnStatisticsData();
                OptionalLong max = data.maximumLength() != null ? OptionalLong.of(data.maximumLength()) : OptionalLong.empty();
                OptionalDouble avg = data.averageLength() != null ? OptionalDouble.of(data.averageLength()) : OptionalDouble.empty();
                OptionalLong nullsCount = data.numberOfNulls() != null ? fromMetastoreNullsCount(data.numberOfNulls()) : OptionalLong.empty();
                OptionalLong distinctValues = data.numberOfDistinctValues() != null ? OptionalLong.of(data.numberOfDistinctValues()) : OptionalLong.empty();
                return createStringColumnStatistics(
                        max,
                        getTotalSizeInBytes(avg, rowCount, nullsCount),
                        nullsCount,
                        fromMetastoreDistinctValuesCount(distinctValues, nullsCount, rowCount));
            }
            case UNKNOWN_TO_SDK_VERSION: {
                throw new PrestoException(HIVE_INVALID_METADATA, "Invalid column statistics data: " + glueStatsData);
            }
        }

        throw new PrestoException(HIVE_INVALID_METADATA, "Invalid column statistics data: " + glueStatsData);
    }

    private static ColumnStatisticsData toGlueColumnStatisticsData(
            HiveColumnStatistics hiveStats,
            HiveType columnType,
            OptionalLong rowCount)
    {
        TypeInfo typeInfo = columnType.getTypeInfo();
        checkArgument(typeInfo.getCategory() == PRIMITIVE, "Unsupported statistics type: %s", columnType);

        ColumnStatisticsData.Builder glueStatsData = ColumnStatisticsData.builder();

        switch (((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory()) {
            case BOOLEAN: {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade the Presto build/AWS SDK to a version that recognizes the new statistics type
  2. Re-run ANALYZE with a compatible engine to rewrite statistics in a known type
  3. Delete the stale Glue column statistics so they are not read
Defensive patterns

Strategy: try-catch

Try / catch

try {
    HiveColumnStatistics stats = fromGlueColumnStatistics(glueStatsData);
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("HIVE_INVALID_METADATA")) {
        // fall back to empty/unknown statistics instead of failing the query
    } else throw e;
}

Prevention

When it happens

Trigger: Reading column statistics from Glue where the recorded ColumnStatisticsType is a value produced by a newer AWS SDK/engine than the one in use.

Common situations: AWS adding a new statistics type; mixed engine versions writing ANALYZE results that older Presto cannot parse.

Related errors


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