apache/druid · error · IllegalStateException
Object is not of a type that can deserialize to sketch: %s
Error message
Object is not of a type that can deserialize to sketch: %s
What it means
ArrayOfDoublesSketchOperations.deserialize() only accepts String (base64), byte[], or an already-deserialized ArrayOfDoublesSketch. Any other object type reaches the final ISE, which reports the offending class. This is a type-guard failure in sketch deserialization.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java:116
{
final double[] result = new double[a.length];
for (int i = 0; i < a.length; i++) {
result[i] = a[i] + b[i];
}
return result;
}
};
public static ArrayOfDoublesSketch 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 ArrayOfDoublesSketch) {
return (ArrayOfDoublesSketch) serializedSketch;
}
throw new ISE("Object is not of a type that can deserialize to sketch: %s", serializedSketch.getClass());
}
public static ArrayOfDoublesSketch 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 ArrayOfDoublesSketch deserializeFromBase64EncodedString(final String str)
{
return deserializeFromByteArray(StringUtils.decodeBase64(str.getBytes(StandardCharsets.UTF_8)));
}
View on GitHub (pinned to 9b90983fd2)
Solutions
- Inspect the reported class name in the message to see what was actually passed
- Use deserializeSafe() which returns null instead of throwing for unusable objects
- Ensure the source column/aggregator genuinely produces ArrayOfDoublesSketch objects
- Convert the object to byte[] or base64 String before deserializing
Example fix
// before
ArrayOfDoublesSketch sketch = ArrayOfDoublesSketchOperations.deserialize(obj);
// after
ArrayOfDoublesSketch sketch = ArrayOfDoublesSketchOperations.deserializeSafe(obj);
if (sketch == null) {
// handle non-sketch object
} Defensive patterns
Strategy: type-guard
Validate before calling
if (!(obj instanceof String) && !(obj instanceof byte[]) && !(obj instanceof ArrayOfDoublesSketch)) {
throw new IllegalStateException("Cannot deserialize to sketch: " + obj.getClass());
} Type guard
boolean isDeserializable = obj instanceof String
|| obj instanceof byte[]
|| obj instanceof ArrayOfDoublesSketch; Try / catch
try {
ArrayOfDoublesSketch s = ArrayOfDoublesSketchOperations.deserialize(obj);
} catch (IllegalStateException e) {
// handle non-sketch object, e.g. log and treat as empty/null
} Prevention
- Use deserializeSafe() when input type is uncertain
- Confirm the source column is produced by a sketch aggregator
- Check for schema/version drift in stored data
When it happens
Trigger: Calling deserialize(Object) with an object that is none of String, byte[], or ArrayOfDoublesSketch — e.g. a Map, List, or Numeric value returned by an expression or stored in a column.
Common situations: Query results where the column does not actually contain a serialized sketch (wrong column chosen, aggregator changed, older data written with a different type); passing a Calcite/Java object of the wrong type into deserialize directly.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- 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
- Object is not of a type that can be deserialized to a quanti
- 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/d96dbc0c2ee01c93.
Report an issue: GitHub.