{"record":{"id":"4b1021c22167952f","repo":"apache/druid","slug":"object-is-not-of-a-type-s-that-can-be-deserializ","errorCode":null,"errorMessage":"Object is not of a type[%s] that can be deserialized to sketch.","messagePattern":"Object is not of a type\\[(.+?)\\] that can be deserialized to sketch\\.","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchHolder.java","lineNumber":52,"sourceCode":"    if (obj == null) {\n      throw new NullPointerException(\"HllSketchHolder.fromObj cannot take a null argument\");\n    }\n\n    if (obj instanceof HllSketchHolder) {\n      return (HllSketchHolder) obj;\n    } else if (obj instanceof HllSketch) {\n      return HllSketchHolder.of((HllSketch) obj);\n    } else if (obj instanceof Union) {\n      return HllSketchHolder.of((Union) obj);\n    } else if (obj instanceof byte[]) {\n      return HllSketchHolder.of(HllSketch.heapify((byte[]) obj));\n    } else if (obj instanceof Memory) {\n      return HllSketchHolder.of(HllSketch.wrap((Memory) obj));\n    } else if (obj instanceof String) {\n      return HllSketchHolder.of(HllSketch.heapify(StringUtils.decodeBase64(StringUtils.toUtf8((String) obj))));\n    }\n\n    throw new ISE(\"Object is not of a type[%s] that can be deserialized to sketch.\", obj.getClass());\n  }\n\n  public static HllSketchHolder of(Union union)\n  {\n    return new HllSketchHolder(union, null);\n  }\n\n  public static HllSketchHolder of(HllSketch sketch)\n  {\n    return new HllSketchHolder(null, sketch);\n  }\n\n  private Union union;\n  private HllSketch sketch;\n\n  public HllSketchHolder(\n      Union union,\n      HllSketch sketch","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchHolder.java#L34-L70","documentation":"fromObj only understands HllSketchHolder, HllSketch, Memory (off-heap sketch), and base64-encoded String inputs. Any other object type cannot be converted into a sketch, so an IllegalStateException with the offending class is thrown. This guards against silently misinterpreting values like Map or ByteBuffer as sketch payloads.","triggerScenarios":"Passing an object of an unsupported class (e.g. byte[], ByteBuffer, Map, StructuredData) to HllSketchHolder.fromObj, typically when the serialized column was produced by a different sketch type or an older/other extension (e.g. HyperLogLog vs HLL++).","commonSituations":"Mixing druid-datasketches versions where serialization format changed; ingesting metrics written by the old com.yahoo.sketches HLL extension; passing the wrong column name so a non-sketch field is fed to the aggregator.","solutions":["Log/inspect obj.getClass() to identify the actual stored type and confirm the column contains HLL sketches","Ensure both writer and reader use the org.apache.druid.query.aggregation.datasketches.hll extension (not the legacy yahoo HLL extension)","If input is byte[] or ByteBuffer, wrap it in Memory (Memory.wrap) or base64-encode it into a String before calling fromObj"],"exampleFix":"// before\nHllSketchHolder holder = HllSketchHolder.fromObj(byteArrayValue);\n// after\nHllSketchHolder holder = HllSketchHolder.fromObj(Memory.wrap(byteArrayValue));","handlingStrategy":"type-guard","validationCode":"if (!(obj instanceof HllSketchHolder || obj instanceof HllSketch || obj instanceof Memory || obj instanceof String)) { throw new IllegalArgumentException(\"Unsupported sketch input: \" + obj.getClass()); }","typeGuard":"boolean isDeserializableSketch(Object o) { return o instanceof HllSketchHolder || o instanceof HllSketch || o instanceof Memory || o instanceof String; }","tryCatchPattern":"try { holder = HllSketchHolder.fromObj(obj); } catch (IllegalStateException e) { log.warn(\"Bad sketch type: {}\", e.getMessage()); throw e; }","preventionTips":["Verify the column was written by the same datasketches-hll extension version","Never pass byte[]/ByteBuffer directly; wrap with Memory.wrap first","Confirm the column name points at the sketch metric, not another field"],"tags":["type-mismatch","deserialization","datasketches","hll"],"backgroundTag":"incompatible-source-type","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}