{"record":{"id":"cea4975e95c105e8","repo":"apache/druid","slug":"object-is-not-of-a-type-that-can-be-deserialized-t","errorCode":null,"errorMessage":"Object is not of a type that can be deserialized to a quantiles DoublesSketch: %s","messagePattern":"Object is not of a type that can be deserialized to a quantiles DoublesSketch: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":500,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchOperations.java","lineNumber":44,"sourceCode":"import org.apache.druid.segment.data.SafeWritableMemory;\n\nimport java.nio.charset.StandardCharsets;\n\npublic class KllDoublesSketchOperations\n{\n\n  public static final KllDoublesSketch EMPTY_SKETCH = KllDoublesSketch.newHeapInstance();\n\n  public static KllDoublesSketch deserialize(final Object serializedSketch)\n  {\n    if (serializedSketch instanceof String) {\n      return deserializeFromBase64EncodedString((String) serializedSketch);\n    } else if (serializedSketch instanceof byte[]) {\n      return deserializeFromByteArray((byte[]) serializedSketch);\n    } else if (serializedSketch instanceof KllDoublesSketch) {\n      return (KllDoublesSketch) serializedSketch;\n    }\n    throw new ISE(\n        \"Object is not of a type that can be deserialized to a quantiles DoublesSketch: %s\",\n        serializedSketch == null ? \"null\" : serializedSketch.getClass()\n    );\n  }\n\n  public static KllDoublesSketch deserializeSafe(final Object serializedSketch)\n  {\n    if (serializedSketch instanceof String) {\n      return deserializeFromBase64EncodedStringSafe((String) serializedSketch);\n    } else if (serializedSketch instanceof byte[]) {\n      return deserializeFromByteArraySafe((byte[]) serializedSketch);\n    }\n    return deserialize(serializedSketch);\n  }\n\n  public static KllDoublesSketch deserializeFromBase64EncodedString(final String str)\n  {\n    return deserializeFromByteArray(StringUtils.decodeBase64(str.getBytes(StandardCharsets.UTF_8)));","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchOperations.java#L26-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nKllDoublesSketch sketch = KllDoublesSketchOperations.deserialize(someMap.get(\"col\"));\n// after\nObject val = someMap.get(\"col\");\nKllDoublesSketch sketch = (val instanceof String || val instanceof byte[] || val instanceof KllDoublesSketch)\n    ? KllDoublesSketchOperations.deserialize(val) : null;","handlingStrategy":"type-guard","validationCode":"Object v = input;\nif (!(v instanceof String || v instanceof byte[] || v instanceof KllDoublesSketch)) {\n  throw new IllegalArgumentException(\"Unsupported sketch input: \" + (v == null ? \"null\" : v.getClass()));\n}","typeGuard":"boolean isDeserializable(Object o) { return o instanceof String || o instanceof byte[] || o instanceof KllDoublesSketch; }","tryCatchPattern":"try { sketch = KllDoublesSketchOperations.deserialize(obj); } catch (IllegalStateException e) { log.warn(\"Bad sketch input\", e); sketch = null; }","preventionTips":["Ensure sketch columns are ingested with the kllDoublesSketch aggregator","Null-check fields before post-aggregation","Never mix quantiles DoublesSketch objects with Kll processing"],"tags":["druid","datasketches","kll","deserialization","type-mismatch"],"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"}