{"record":{"id":"48dd76389205735f","repo":"apache/druid","slug":"object-cannot-be-deserialized-to-a-ddsketch-sketch","errorCode":null,"errorMessage":"Object cannot be deserialized to a DDSketch Sketch: \" + serializedSketch.getClass()","messagePattern":"Object cannot be deserialized to a DDSketch Sketch: \" \\+ serializedSketch\\.getClass\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/ddsketch/src/main/java/org/apache/druid/query/aggregation/ddsketch/DDSketchUtils.java","lineNumber":55,"sourceCode":"  }\n\n  public static DDSketch deserialize(Object serializedSketch)\n  {\n    try {\n      if (serializedSketch instanceof String) {\n        String str = (String) serializedSketch;\n        byte[] bytes = StringUtils.decodeBase64(StringUtils.toUtf8(str));\n        com.datadoghq.sketch.ddsketch.proto.DDSketch proto = com.datadoghq.sketch.ddsketch.proto.DDSketch.parseFrom(bytes);\n        DDSketch recovered = DDSketchProtoBinding.fromProto(() -> new CollapsingLowestDenseStore(1000), proto);\n        return recovered;\n      } else if (serializedSketch instanceof byte[]) {\n        com.datadoghq.sketch.ddsketch.proto.DDSketch proto = com.datadoghq.sketch.ddsketch.proto.DDSketch.parseFrom((byte[]) serializedSketch);\n        DDSketch recovered = DDSketchProtoBinding.fromProto(() -> new CollapsingLowestDenseStore(1000), proto);\n        return recovered;\n      } \n    }\n    catch (InvalidProtocolBufferException e) {\n      throw new IAE(\n          \"Object cannot be deserialized to a DDSketch Sketch: \"\n          + serializedSketch.getClass()\n      );\n    }\n    if (serializedSketch instanceof DDSketch) {\n      return (DDSketch) serializedSketch;\n    }\n    throw new IAE(\n        \"Object cannot be deserialized to a DDSketch Sketch: \"\n        + serializedSketch.getClass()\n    );\n  }\n\n  static byte[] toBytes(DDSketch sketch)\n  {\n    return DDSketchProtoBinding.toProto(sketch).toByteArray();\n  }\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/ddsketch/src/main/java/org/apache/druid/query/aggregation/ddsketch/DDSketchUtils.java#L37-L73","documentation":"DDSketchUtils.deserialize accepts a base64 String or a raw byte[] protobuf sketch; any other object type (e.g. a Map decoded from JSON) reaches the final throw because it cannot be decoded into a DDSketch.","triggerScenarios":"Thrown at extensions-contrib/ddsketch/src/main/java/org/apache/druid/query/aggregation/ddsketch/DDSketchUtils.java:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the value was produced by DDSketchUtils.serialize (base64 String or byte[]).","Fix the query/ingestion wiring that passes the wrong object type."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}