apache/druid · error · ISE
Object is not of a type[%s] that can be deserialized to sket
Error message
Object is not of a type[%s] that can be deserialized to sketch.
What it means
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.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchHolder.java:52
if (obj == null) {
throw new NullPointerException("HllSketchHolder.fromObj cannot take a null argument");
}
if (obj instanceof HllSketchHolder) {
return (HllSketchHolder) obj;
} else if (obj instanceof HllSketch) {
return HllSketchHolder.of((HllSketch) obj);
} else if (obj instanceof Union) {
return HllSketchHolder.of((Union) obj);
} else if (obj instanceof byte[]) {
return HllSketchHolder.of(HllSketch.heapify((byte[]) obj));
} else if (obj instanceof Memory) {
return HllSketchHolder.of(HllSketch.wrap((Memory) obj));
} else if (obj instanceof String) {
return HllSketchHolder.of(HllSketch.heapify(StringUtils.decodeBase64(StringUtils.toUtf8((String) obj))));
}
throw new ISE("Object is not of a type[%s] that can be deserialized to sketch.", obj.getClass());
}
public static HllSketchHolder of(Union union)
{
return new HllSketchHolder(union, null);
}
public static HllSketchHolder of(HllSketch sketch)
{
return new HllSketchHolder(null, sketch);
}
private Union union;
private HllSketch sketch;
public HllSketchHolder(
Union union,
HllSketch sketchView on GitHub (pinned to 9b90983fd2)
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
Example fix
// before HllSketchHolder holder = HllSketchHolder.fromObj(byteArrayValue); // after HllSketchHolder holder = HllSketchHolder.fromObj(Memory.wrap(byteArrayValue));
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(obj instanceof HllSketchHolder || obj instanceof HllSketch || obj instanceof Memory || obj instanceof String)) { throw new IllegalArgumentException("Unsupported sketch input: " + obj.getClass()); } Type guard
boolean isDeserializableSketch(Object o) { return o instanceof HllSketchHolder || o instanceof HllSketch || o instanceof Memory || o instanceof String; } Try / catch
try { holder = HllSketchHolder.fromObj(obj); } catch (IllegalStateException e) { log.warn("Bad sketch type: {}", e.getMessage()); throw e; } Prevention
- 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
When it happens
Trigger: 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++).
Common situations: 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.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Invalid input [%s] of type [%s] for [%s] aggregator [%s]
- Unsupported type %s
- HllSketchHolder.fromObj cannot take a null argument
- Object is not of a type that can be deserialized to a quanti
- Object is not of a type that can be deserialized to a KllFlo
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/4b1021c22167952f.
Report an issue: GitHub.