{"record":{"id":"11c9b2117bc56508","repo":"apache/iceberg","slug":"unsupported-data-statistics-type-statisticstype-11c9b2","errorCode":null,"errorMessage":"Unsupported data statistics type: ${statisticsType}","messagePattern":"Unsupported data statistics type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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.1/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/DataStatisticsSerializer.java#L73-L109","documentation":"DataStatisticsSerializer.copy supports copying statistics objects of known StatisticsType values; when the type is neither Map nor Sketch it cannot pick a copy strategy and throws. The type comes from the DataStatistics object being copied, so an unsupported value implies an unknown/newer statistics implementation.","triggerScenarios":"Calling copy() on a DataStatistics whose type() returns a StatisticsType other than Map or Sketch, e.g. a statistics object created by a newer connector version.","commonSituations":"Mixed connector versions across the Flink cluster during the data-statistics shuffle handshake, or custom DataStatistics implementations passed into the serializer.","solutions":["Align Iceberg connector versions on all nodes of the Flink job.","Only feed DataStatistics instances produced by this serializer/connector (Map or Sketch types).","Upgrade the connector so newer statistics types are recognized."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"StatisticsType t = from.type();\nif (t != StatisticsType.Map && t != StatisticsType.Sketch) {\n  throw new IllegalArgumentException(\"Cannot copy statistics of type \" + t);\n}","typeGuard":"boolean isCopyable(DataStatistics s) {\n  return s.type() == StatisticsType.Map || s.type() == StatisticsType.Sketch;\n}","tryCatchPattern":"try {\n  DataStatistics copy = serializer.copy(from, null);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported data statistics type\")) {\n    // fall back to map-based statistics or re-create from raw data\n  } else throw e;\n}","preventionTips":["Only exchange DataStatistics produced by the same connector version.","Keep StatisticsType handling in sync when extending the library.","Avoid mixed connector jars on the cluster classpath."],"tags":["flink","serialization","statistics"],"backgroundTag":"unsupported-enum-value","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"}