{"record":{"id":"977b8721c1744dff","repo":"prestodb/presto","slug":"hive-invalid-metadata-977b87","errorCode":"HIVE_INVALID_METADATA","errorMessage":"Invalid column statistics data: + glueStatsData","messagePattern":"Invalid column statistics data: \\+ glueStatsData","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueStatisticsConverter.java","lineNumber":281,"sourceCode":"                        min,\n                        max,\n                        nullsCount,\n                        fromMetastoreDistinctValuesCount(distinctValues, nullsCount, rowCount));\n            }\n            case STRING: {\n                StringColumnStatisticsData data = glueStatsData.stringColumnStatisticsData();\n                OptionalLong max = data.maximumLength() != null ? OptionalLong.of(data.maximumLength()) : OptionalLong.empty();\n                OptionalDouble avg = data.averageLength() != null ? OptionalDouble.of(data.averageLength()) : OptionalDouble.empty();\n                OptionalLong nullsCount = data.numberOfNulls() != null ? fromMetastoreNullsCount(data.numberOfNulls()) : OptionalLong.empty();\n                OptionalLong distinctValues = data.numberOfDistinctValues() != null ? OptionalLong.of(data.numberOfDistinctValues()) : OptionalLong.empty();\n                return createStringColumnStatistics(\n                        max,\n                        getTotalSizeInBytes(avg, rowCount, nullsCount),\n                        nullsCount,\n                        fromMetastoreDistinctValuesCount(distinctValues, nullsCount, rowCount));\n            }\n            case UNKNOWN_TO_SDK_VERSION: {\n                throw new PrestoException(HIVE_INVALID_METADATA, \"Invalid column statistics data: \" + glueStatsData);\n            }\n        }\n\n        throw new PrestoException(HIVE_INVALID_METADATA, \"Invalid column statistics data: \" + glueStatsData);\n    }\n\n    private static ColumnStatisticsData toGlueColumnStatisticsData(\n            HiveColumnStatistics hiveStats,\n            HiveType columnType,\n            OptionalLong rowCount)\n    {\n        TypeInfo typeInfo = columnType.getTypeInfo();\n        checkArgument(typeInfo.getCategory() == PRIMITIVE, \"Unsupported statistics type: %s\", columnType);\n\n        ColumnStatisticsData.Builder glueStatsData = ColumnStatisticsData.builder();\n\n        switch (((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory()) {\n            case BOOLEAN: {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueStatisticsConverter.java#L263-L299","documentation":"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.","triggerScenarios":"Reading column statistics from Glue where the recorded ColumnStatisticsType is a value produced by a newer AWS SDK/engine than the one in use.","commonSituations":"AWS adding a new statistics type; mixed engine versions writing ANALYZE results that older Presto cannot parse.","solutions":["Upgrade the Presto build/AWS SDK to a version that recognizes the new statistics type","Re-run ANALYZE with a compatible engine to rewrite statistics in a known type","Delete the stale Glue column statistics so they are not read"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    HiveColumnStatistics stats = fromGlueColumnStatistics(glueStatsData);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"HIVE_INVALID_METADATA\")) {\n        // fall back to empty/unknown statistics instead of failing the query\n    } else throw e;\n}","preventionTips":["Keep AWS SDK and Presto versions current","Re-run ANALYZE after engine upgrades","Avoid manually editing Glue statistics"],"tags":["glue","statistics","invalid-metadata","sdk-version"],"backgroundTag":"invalid-column-statistics","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}