{"record":{"id":"18cb044e135d3b66","repo":"apache/druid","slug":"unknwon-types-s-and-s","errorCode":null,"errorMessage":"Unknwon types [%s] and [%s]","messagePattern":"Unknwon types \\[(.+?)\\] and \\[(.+?)\\]","errorType":"exception","errorClass":"org.apache.druid.java.util.common.IAE","httpStatus":null,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java","lineNumber":79,"sourceCode":"          SketchHolder h2 = (SketchHolder) o2;\n\n          if (h1.obj instanceof Sketch || h1.obj instanceof Union) {\n            if (h2.obj instanceof Sketch || h2.obj instanceof Union) {\n              return SKETCH_COMPARATOR.compare(h1.getSketch(), h2.getSketch());\n            } else {\n              return -1;\n            }\n          }\n\n          if (h1.obj instanceof Memory) {\n            if (h2.obj instanceof Memory) {\n              return MEMORY_COMPARATOR.compare((Memory) h1.obj, (Memory) h2.obj);\n            } else {\n              return 1;\n            }\n          }\n\n          throw new IAE(\"Unknwon types [%s] and [%s]\", h1.obj.getClass().getName(), h2.obj.getClass().getName());\n        }\n      }\n  ).nullsFirst();\n\n  private static final Comparator<Sketch> SKETCH_COMPARATOR = new Comparator<>()\n  {\n    @Override\n    public int compare(Sketch o1, Sketch o2)\n    {\n      return Doubles.compare(o1.getEstimate(), o2.getEstimate());\n    }\n  };\n\n  private static final Comparator<Memory> MEMORY_COMPARATOR = new Comparator<>()\n  {\n    @SuppressWarnings(\"SubtractionInCompareTo\")\n    @Override\n    public int compare(Memory o1, Memory o2)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java#L61-L97","documentation":"SketchHolder.COMPARATOR (used for ordering/merging sketch values) only knows how to compare Sketch and Memory objects; comparing SketchHolders holding any other object type throws this IllegalArgumentException (note the typo \"Unknwon\"). It surfaces when two incompatible value types meet in a comparator, typically during sorting or query result combination.","triggerScenarios":"Comparing two SketchHolder instances whose obj fields are neither both Sketch nor both Memory — e.g. one is a String (serialized sketch) and the other a Sketch, or one is from a different sketch family.","commonSituations":"Order-by over a theta sketch column with heterogeneous serialized forms; merging results where one segment stored Memory-wrapped sketches and another stored deserialized Sketches or strings; joining outputs of different sketch types.","solutions":["Normalize sketch values to a common representation (deserialize Memory/String to Sketch before comparing)","Ensure all segments/columns involved hold the same theta sketch type and serialization","Catch and pre-convert string-encoded sketches before operations that sort or compare them"],"exampleFix":"// before\nSketchHolder a = SketchHolder.of(sketch); SketchHolder b = SketchHolder.of(\"deadbeef\"); // String\na.compareTo(b); // IAE\n// after\nSketchHolder b2 = SketchHolder.of(Sketches.wrapSketch(SketchSerialization.decode((String) b.obj)));","handlingStrategy":"type-guard","validationCode":"if (!(h1.obj.getClass().equals(h2.obj.getClass())) || !(h1.obj instanceof Sketch || h1.obj instanceof Memory)) { throw new IllegalArgumentException(\"Incompatible sketch holder types: \" + h1.obj.getClass() + \" vs \" + h2.obj.getClass()); }","typeGuard":"boolean comparableHolders(SketchHolder a, SketchHolder b) { return (a.obj instanceof Sketch && b.obj instanceof Sketch) || (a.obj instanceof Memory && b.obj instanceof Memory); }","tryCatchPattern":"try { c = a.compareTo(b); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Unknwon types\")) { c = compareAsSketches(a, b); } else throw e; }","preventionTips":["Normalize SketchHolders to a single representation (Sketch) before sorting/merging","Do not mix String-serialized and deserialized sketches in one result set","Ensure consistent sketch type across all queried segments"],"tags":["java","datasketches","theta-sketch","type-mismatch","comparison"],"backgroundTag":"type-mismatch","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"}