{"record":{"id":"79edadfd60632ade","repo":"apache/iceberg","slug":"unsupported-data-statistics-type-statisticsty","errorCode":null,"errorMessage":"Unsupported data statistics type: \" + statisticsType","messagePattern":"Unsupported data statistics type: \" \\+ statisticsType","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/DataStatisticsSerializer.java","lineNumber":91,"sourceCode":"  public DataStatistics copy(DataStatistics obj) {\n    StatisticsType statisticsType = obj.type();\n    if (statisticsType == StatisticsType.Map) {\n      MapDataStatistics from = (MapDataStatistics) obj;\n      Map<SortKey, Long> fromStats = (Map<SortKey, Long>) from.result();\n      Map<SortKey, Long> toStats = Maps.newHashMap(fromStats);\n      return new MapDataStatistics(toStats);\n    } else if (statisticsType == StatisticsType.Sketch) {\n      // because ReservoirItemsSketch doesn't expose enough public methods for cloning,\n      // this implementation adopted the less efficient serialization and deserialization.\n      SketchDataStatistics from = (SketchDataStatistics) obj;\n      ReservoirItemsSketch<SortKey> fromStats = (ReservoirItemsSketch<SortKey>) from.result();\n      byte[] bytes = fromStats.toByteArray(sketchSerializer);\n      Memory memory = Memory.wrap(bytes);\n      ReservoirItemsSketch<SortKey> toStats =\n          ReservoirItemsSketch.heapify(memory, sketchSerializer);\n      return new SketchDataStatistics(toStats);\n    } else {\n      throw new IllegalArgumentException(\"Unsupported data statistics type: \" + statisticsType);\n    }\n  }\n\n  @Override\n  public DataStatistics copy(DataStatistics from, DataStatistics reuse) {\n    // not much benefit to reuse\n    return copy(from);\n  }\n\n  @Override\n  public int getLength() {\n    return -1;\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  @Override\n  public void serialize(DataStatistics obj, DataOutputView target) throws IOException {\n    StatisticsType statisticsType = obj.type();","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/DataStatisticsSerializer.java#L73-L109","documentation":"DataStatisticsSerializer (type serializer for DataStatistics) supports a fixed set of statistics types (e.g. sketch-based reservoir statistics). Deserializing bytes whose statisticsType byte is unrecognized throws IllegalArgumentException because it cannot reconstruct the DataStatistics instance.","triggerScenarios":"Restoring checkpoints/savepoints written by a newer Iceberg version that serialized a statistics type the current runtime does not know, or corrupt state bytes flipping the type field.","commonSituations":"Version skew between writer and restorer jobs using the sink-shuffle data statistics feature; corrupted state backend data.","solutions":["Restore with the same or newer Iceberg version that wrote the state","Rewrite the savepoint with the current version before restoring","Check state backend integrity if the type byte appears corrupted"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// restore only state written by a known-compatible version\nif (!runningVersion.equals(stateWrittenVersion)) {\n  fail(\"DataStatistics state version mismatch\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  stats = serializer.deserialize(version, bytes);\n} catch (IllegalArgumentException e) {\n  throw new StateMigrationException(\"Unsupported statistics type in state\", e);\n}","preventionTips":["Avoid version skew between the job that wrote the checkpoint and the restoring job","Re-take savepoints after Iceberg upgrades","Validate state backend files against corruption"],"tags":["flink","serialization","checkpoint"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}