apache/druid · error · IllegalArgumentException
Object cannot be deserialized to a DDSketch Sketch: " +…
Error message
Object cannot be deserialized to a DDSketch Sketch: " + serializedSketch.getClass()
What it means
DDSketchUtils.deserialize accepts a base64 String or a raw byte[] protobuf sketch; any other object type (e.g. a Map decoded from JSON) reaches the final throw because it cannot be decoded into a DDSketch.
Solutions
- Ensure the value was produced by DDSketchUtils.serialize (base64 String or byte[]).
- Fix the query/ingestion wiring that passes the wrong object type.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at extensions-contrib/ddsketch/src/main/java/org/apache/druid/query/aggregation/ddsketch/DDSketchUtils.java:55 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/48dd76389205735f.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-contrib/ddsketch/src/main/java/org/apache/druid/query/aggregation/ddsketch/DDSketchUtils.java:55
}
public static DDSketch deserialize(Object serializedSketch)
{
try {
if (serializedSketch instanceof String) {
String str = (String) serializedSketch;
byte[] bytes = StringUtils.decodeBase64(StringUtils.toUtf8(str));
com.datadoghq.sketch.ddsketch.proto.DDSketch proto = com.datadoghq.sketch.ddsketch.proto.DDSketch.parseFrom(bytes);
DDSketch recovered = DDSketchProtoBinding.fromProto(() -> new CollapsingLowestDenseStore(1000), proto);
return recovered;
} else if (serializedSketch instanceof byte[]) {
com.datadoghq.sketch.ddsketch.proto.DDSketch proto = com.datadoghq.sketch.ddsketch.proto.DDSketch.parseFrom((byte[]) serializedSketch);
DDSketch recovered = DDSketchProtoBinding.fromProto(() -> new CollapsingLowestDenseStore(1000), proto);
return recovered;
}
}
catch (InvalidProtocolBufferException e) {
throw new IAE(
"Object cannot be deserialized to a DDSketch Sketch: "
+ serializedSketch.getClass()
);
}
if (serializedSketch instanceof DDSketch) {
return (DDSketch) serializedSketch;
}
throw new IAE(
"Object cannot be deserialized to a DDSketch Sketch: "
+ serializedSketch.getClass()
);
}
static byte[] toBytes(DDSketch sketch)
{
return DDSketchProtoBinding.toProto(sketch).toByteArray();
}
View on GitHub (pinned to 9b90983fd2)