{"record":{"id":"2dfe6e616b894f19","repo":"apache/druid","slug":"object-is-not-of-a-type-s-that-can-be-deserializ-2dfe6e","errorCode":null,"errorMessage":"Object is not of a type[%s] that can be deserialized to HyperLogLog.","messagePattern":"Object is not of a type\\[(.+?)\\] that can be deserialized to HyperLogLog\\.","errorType":"exception","errorClass":"org.apache.druid.java.util.common.ISE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java","lineNumber":66,"sourceCode":"      }\n\n      @Override\n      public HyperLogLogCollector extractValue(InputRow inputRow, String metricName)\n      {\n        Object rawValue = inputRow.getRaw(metricName);\n\n        if (rawValue == null) {\n          return HyperLogLogCollector.makeLatestCollector();\n        } else if (rawValue instanceof HyperLogLogCollector) {\n          return (HyperLogLogCollector) rawValue;\n        } else if (rawValue instanceof byte[]) {\n          return HyperLogLogCollector.makeLatestCollector().fold(ByteBuffer.wrap((byte[]) rawValue));\n        } else if (rawValue instanceof String) {\n          return HyperLogLogCollector.makeLatestCollector()\n                                     .fold(ByteBuffer.wrap(StringUtils.decodeBase64String((String) rawValue)));\n        }\n\n        throw new ISE(\"Object is not of a type[%s] that can be deserialized to HyperLogLog.\", rawValue.getClass());\n      }\n    };\n  }\n}\n","sourceCodeStart":48,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java#L48-L71","documentation":"PreComputedHyperUniquesSerde's extraction lambda deserializes a stored value into a HyperLogLogCollector, accepting byte[] and base64-String forms. When the raw value under a hyperUnique-typed column is neither (e.g. a Number, Map, or other object), it throws an IllegalStateException indicating the stored object type cannot be converted to an HLL sketch.","triggerScenarios":"Segment data written under a hyperUnique column contains a value whose runtime type is not byte[] or String — e.g. segments ingested with a different spec (numeric column), corrupted/incorrectly typed segment files, or a serde mismatch between writer and reader versions.","commonSituations":"Reindexing segments that originally stored plain numbers under the same column name later declared as hyperUnique; manual segment manipulation or heterogeneous ingestion jobs writing mixed types to one column; schema changes where rollup/ingestion swapped column type without re-ingesting.","solutions":["Re-ingest the affected segments with the hyperUnique (or sketch) column type so values are stored as serialized HLL byte arrays.","Check the ingestion spec: ensure the column configured as hyperUnique actually receives sketches (e.g. from a counter/dimension via appropriate aggregator), not raw numbers.","Inspect offending segments (segment metadata/dump) to identify which rows hold the wrong type, then replace those segments."],"exampleFix":"// before: column \"u\" ingested as a long, later queried as hyperUnique\n// after: ingest with\n{\"type\":\"hyperUnique\",\"name\":\"u\",\"fieldName\":\"u_raw\"}\nso segments store HLL byte[] values readable by PreComputedHyperUniquesSerde.","handlingStrategy":"validation","validationCode":"if (!(rawValue instanceof byte[]) && !(rawValue instanceof String)) { throw new IllegalArgumentException(\"Column value for hyperUnique must be byte[] or base64 String, got \" + rawValue.getClass()); }","typeGuard":"boolean isHllSerializable(Object v) { return v instanceof byte[] || v instanceof String; }","tryCatchPattern":"try { serde.extractValue(value); } catch (IllegalStateException e) { log.error(\"Segment holds non-sketch value; re-ingest segment\", e); }","preventionTips":["Keep the ingestion aggregator type and query column type consistent (hyperUnique vs double vs long).","Re-ingest instead of redeclaring column types on existing segments.","Validate segment schemas after schema changes with segment metadata queries.","Avoid manual segment edits that place non-sketch payloads under sketch-typed columns."],"tags":["druid","serde","hyperloglog","deserialization"],"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-14T11:17:12.474Z"}