{"record":{"id":"28262b5a77baa6de","repo":"apache/iceberg","slug":"fail-to-deserialize-data-statistics","errorCode":null,"errorMessage":"Fail to deserialize data statistics","messagePattern":"Fail to deserialize data statistics","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/StatisticsUtil.java","lineNumber":59,"sourceCode":"\n  static byte[] serializeDataStatistics(\n      DataStatistics dataStatistics, TypeSerializer<DataStatistics> statisticsSerializer) {\n    DataOutputSerializer out = new DataOutputSerializer(64);\n    try {\n      statisticsSerializer.serialize(dataStatistics, out);\n      return out.getCopyOfBuffer();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Fail to serialize data statistics\", e);\n    }\n  }\n\n  static DataStatistics deserializeDataStatistics(\n      byte[] bytes, TypeSerializer<DataStatistics> statisticsSerializer) {\n    DataInputDeserializer input = new DataInputDeserializer(bytes, 0, bytes.length);\n    try {\n      return statisticsSerializer.deserialize(input);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Fail to deserialize data statistics\", e);\n    }\n  }\n\n  static byte[] serializeCompletedStatistics(\n      CompletedStatistics completedStatistics,\n      TypeSerializer<CompletedStatistics> statisticsSerializer) {\n    try {\n      DataOutputSerializer out = new DataOutputSerializer(1024);\n      statisticsSerializer.serialize(completedStatistics, out);\n      return out.getCopyOfBuffer();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Fail to serialize aggregated statistics\", e);\n    }\n  }\n\n  static CompletedStatistics deserializeCompletedStatistics(\n      byte[] bytes, CompletedStatisticsSerializer statisticsSerializer) {\n    try {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/StatisticsUtil.java#L41-L77","documentation":"UncheckedIOException thrown by StatisticsUtil.deserializeDataStatistics when the stored bytes cannot be read back into a DataStatistics object using the supplied TypeSerializer. The wrapped IOException usually indicates truncated, corrupt, or version-mismatched state bytes.","triggerScenarios":"Calling StatisticsUtil.deserializeDataStatistics with bytes produced by a different serializer version or a different DataStatistics format; passing empty or corrupted byte arrays.","commonSituations":"Restoring a Flink job from a checkpoint written by an older Iceberg release; state bytes that were re-encoded or truncated; using the wrong serializer instance (e.g., completed-statistics serializer for data statistics).","solutions":["Use the same serializer that produced the bytes (same Iceberg/Flink version)","Confirm the bytes are non-empty and were produced by serializeDataStatistics","Re-create the statistics from the source (reset operator state) if the checkpoint bytes are from an incompatible version","Inspect the wrapped IOException cause to pinpoint the format mismatch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (bytes == null || bytes.length == 0) { throw new IllegalArgumentException(\"empty statistics bytes\"); }","typeGuard":"boolean hasStatisticsBytes(byte[] bytes) { return bytes != null && bytes.length > 0; }","tryCatchPattern":"try { DataStatistics s = StatisticsUtil.deserializeDataStatistics(bytes, serializer); } catch (UncheckedIOException e) { /* recreate statistics or fail restore */ }","preventionTips":["Use the exact serializer that produced the bytes","Avoid mixing serializer types (data vs completed statistics)","Check checkpoint compatibility before upgrading Iceberg"],"tags":["flink","deserialization"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}