apache/druid · error · IllegalStateException

Object is not of a type that can be deserialized to a KllFlo

Error message

Object is not of a type that can be deserialized to a KllFloatsSketch: %s

What it means

KllFloatsSketchOperations.deserialize accepts only a base64-encoded String, a byte[], or an existing KllFloatsSketch; anything else (including null) triggers IllegalStateException. It guards the coercion of serialized sketch state back into a sketch object in the post-aggregation path.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllFloatsSketchOperations.java:44

import org.apache.druid.segment.data.SafeWritableMemory;

import java.nio.charset.StandardCharsets;

public class KllFloatsSketchOperations
{

  public static final KllFloatsSketch EMPTY_SKETCH = KllFloatsSketch.newHeapInstance();

  public static KllFloatsSketch 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 KllFloatsSketch) {
      return (KllFloatsSketch) serializedSketch;
    }
    throw new ISE(
        "Object is not of a type that can be deserialized to a KllFloatsSketch: %s",
        serializedSketch == null ? "null" : serializedSketch.getClass()
    );
  }

  public static KllFloatsSketch 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 KllFloatsSketch deserializeFromBase64EncodedString(final String str)
  {
    return deserializeFromByteArray(StringUtils.decodeBase64(str.getBytes(StandardCharsets.UTF_8)));

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Verify the column was ingested with the kllFloatsSketch aggregator so values are float sketch payloads
  2. Null-check and type-check inputs (String/byte[]/KllFloatsSketch) before calling deserialize
  3. Use deserializeSafe for tolerant handling instead of raw deserialize
  4. Do not mix KllDoublesSketch values with KllFloatsSketch processing

Example fix

// before
KllFloatsSketch sk = KllFloatsSketchOperations.deserialize(doublesSketchObj);
// after
KllFloatsSketch sk = (obj instanceof String || obj instanceof byte[] || obj instanceof KllFloatsSketch)
    ? KllFloatsSketchOperations.deserialize(obj) : null;
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(obj instanceof String || obj instanceof byte[] || obj instanceof KllFloatsSketch)) {
  throw new IllegalArgumentException("Unsupported KllFloatsSketch input: " + obj);
}

Type guard

boolean isDeserializable(Object o) { return o instanceof String || o instanceof byte[] || o instanceof KllFloatsSketch; }

Try / catch

try { sk = KllFloatsSketchOperations.deserialize(obj); } catch (IllegalStateException e) { log.warn("Bad float sketch input", e); sk = null; }

Prevention

When it happens

Trigger: Passing an object of any other type — List, Map, Number, null, or a KllDoublesSketch — to KllFloatsSketchOperations.deserialize, typically from a wrongly typed column or a mismatched field reference in a post-aggregator.

Common situations: Feeding a doubles-sketch column into a kllFloatsSketch post-aggregator; referencing a raw float column instead of a sketch column; deserialized JSON intermediates that lost the sketch type.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/c5c6a7aa3142b93e. Report an issue: GitHub.