apache/druid · error · IllegalArgumentException
Object cannot be deserialized to a TDigest Sketch:
Error message
Object cannot be deserialized to a TDigest Sketch:
What it means
TDigestSketchUtils.deserialize() is a generic type-guard/normalizer: it accepts a base64 String, a raw byte[], or an already-decoded MergingDigest. The error fires for any other runtime type (or a payload that fails the accepted decoding path), meaning the stored or transmitted sketch value is not in a format this extension can turn into a MergingDigest.
Solutions
- Ensure persisted sketch values are base64 strings or byte[] produced by the tdigestsketch serde
- If the value is a corrupted or truncated base64/byte payload, re-aggregate or re-ingest the affected rows
- Check that no intermediary step (e.g. custom code or a different serde) is substituting another object type for the sketch
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestSketchUtils.java:47 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/f14ff4aefc1b6e06.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestSketchUtils.java:47
public class TDigestSketchUtils
{
// Class is not meant to be instantiated
private TDigestSketchUtils()
{
}
public static MergingDigest deserialize(Object serializedSketch)
{
if (serializedSketch instanceof String) {
String str = (String) serializedSketch;
return MergingDigest.fromBytes(ByteBuffer.wrap(StringUtils.decodeBase64(StringUtils.toUtf8(str))));
} else if (serializedSketch instanceof byte[]) {
return MergingDigest.fromBytes(ByteBuffer.wrap((byte[]) serializedSketch));
} else if (serializedSketch instanceof MergingDigest) {
return (MergingDigest) serializedSketch;
}
throw new IAE(
"Object cannot be deserialized to a TDigest Sketch: "
+ serializedSketch.getClass()
);
}
static byte[] toBytes(MergingDigest tDigest)
{
byte[] arr = new byte[tDigest.byteSize()];
ByteBuffer result = ByteBuffer.wrap(arr);
tDigest.asBytes(result);
return result.array();
}
/**
* This method computes an estimate of the max intermediate size of a {@link MergingDigest}.
* Since there is no utility available in the T-Digest library to compute this size,
* the below code is inspired by looking at
* {@link MergingDigest#MergingDigest(double, int, int)}View on GitHub (pinned to 9b90983fd2)