apache/druid · error · IllegalStateException
Object is not of a type that can be deserialized to a quanti
Error message
Object is not of a type that can be deserialized to a quantiles DoublesSketch: %s
What it means
KllDoublesSketchOperations.deserialize only accepts a base64-encoded String, a byte[], or an already-built KllDoublesSketch. Any other object type (including null) cannot be converted to a sketch, so it throws IllegalStateException. This is a defensive check in the post-aggregator/initializer path where serialized sketch state is coerced.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchOperations.java:44
import org.apache.druid.segment.data.SafeWritableMemory;
import java.nio.charset.StandardCharsets;
public class KllDoublesSketchOperations
{
public static final KllDoublesSketch EMPTY_SKETCH = KllDoublesSketch.newHeapInstance();
public static KllDoublesSketch deserialize(final Object serializedSketch)
{
if (serializedSketch instanceof String) {
return deserializeFromBase64EncodedString((String) serializedSketch);
} else if (serializedSketch instanceof byte[]) {
return deserializeFromByteArray((byte[]) serializedSketch);
} else if (serializedSketch instanceof KllDoublesSketch) {
return (KllDoublesSketch) serializedSketch;
}
throw new ISE(
"Object is not of a type that can be deserialized to a quantiles DoublesSketch: %s",
serializedSketch == null ? "null" : serializedSketch.getClass()
);
}
public static KllDoublesSketch deserializeSafe(final Object serializedSketch)
{
if (serializedSketch instanceof String) {
return deserializeFromBase64EncodedStringSafe((String) serializedSketch);
} else if (serializedSketch instanceof byte[]) {
return deserializeFromByteArraySafe((byte[]) serializedSketch);
}
return deserialize(serializedSketch);
}
public static KllDoublesSketch deserializeFromBase64EncodedString(final String str)
{
return deserializeFromByteArray(StringUtils.decodeBase64(str.getBytes(StandardCharsets.UTF_8)));View on GitHub (pinned to 9b90983fd2)
Solutions
- Verify the underlying column is ingested with the kllDoublesSketch aggregator so stored values are sketch payloads
- Pass base64 String, byte[], or KllDoublesSketch explicitly; null-check before calling deserialize
- Use deserializeSafe if you want null/empty handling instead of raw deserialize
- Confirm you are not mixing the datasketches-quantiles DoublesSketch with KllDoublesSketch types
Example fix
// before
KllDoublesSketch sketch = KllDoublesSketchOperations.deserialize(someMap.get("col"));
// after
Object val = someMap.get("col");
KllDoublesSketch sketch = (val instanceof String || val instanceof byte[] || val instanceof KllDoublesSketch)
? KllDoublesSketchOperations.deserialize(val) : null; Defensive patterns
Strategy: type-guard
Validate before calling
Object v = input;
if (!(v instanceof String || v instanceof byte[] || v instanceof KllDoublesSketch)) {
throw new IllegalArgumentException("Unsupported sketch input: " + (v == null ? "null" : v.getClass()));
} Type guard
boolean isDeserializable(Object o) { return o instanceof String || o instanceof byte[] || o instanceof KllDoublesSketch; } Try / catch
try { sketch = KllDoublesSketchOperations.deserialize(obj); } catch (IllegalStateException e) { log.warn("Bad sketch input", e); sketch = null; } Prevention
- Ensure sketch columns are ingested with the kllDoublesSketch aggregator
- Null-check fields before post-aggregation
- Never mix quantiles DoublesSketch objects with Kll processing
When it happens
Trigger: Passing an Object that is none of String/byte[]/KllDoublesSketch to KllDoublesSketchOperations.deserialize — e.g. a List, Map, Number, or null, usually because the wrong field was fed to a sketch post-aggregator or a column was ingested as a non-sketch type.
Common situations: Pointing a kllDoublesSketch post-aggregator at a plain numeric/string column instead of a sketch-typed column; query results where the intermediate field was serialized to JSON as a non-sketch structure; accidentally passing a QuantilesSketch (different extension) object.
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
- Object is not of a type that can be deserialized to a KllFlo
- Object is not of a type that can be deserialized to a quanti
- Object is not of a type that can deserialize to sketch: %s
- Cannot deserialize type[%s] to an RoaringBitmap64Counter:
- Object is not of a type[%s] that can be deserialized to sket
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/cea4975e95c105e8.
Report an issue: GitHub.