{"record":{"id":"fecf596a0be1c356","repo":"apache/druid","slug":"unsupported-string-encoding-s","errorCode":null,"errorMessage":"Unsupported string encoding [%s]","messagePattern":"Unsupported string encoding \\[(.+?)\\]","errorType":"exception","errorClass":"UOE","httpStatus":null,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchBuildUtil.java","lineNumber":99,"sourceCode":"  private static void updateSketchWithString(\n      final HllSketch sketch,\n      final StringEncoding stringEncoding,\n      @Nullable final String value\n  )\n  {\n    if (value == null) {\n      return;\n    }\n\n    switch (stringEncoding) {\n      case UTF8:\n        sketch.update(StringUtils.toUtf8(value));\n        break;\n      case UTF16LE:\n        sketch.update(value.toCharArray());\n        break;\n      default:\n        throw new UOE(\"Unsupported string encoding [%s]\", stringEncoding);\n    }\n  }\n}\n","sourceCodeStart":81,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchBuildUtil.java#L81-L103","documentation":"HllSketchBuildUtil.updateSketchWithString throws UnsupportedOperationException (UOE) when the configured StringEncoding is neither UTF8 nor UTF16LE. The HLL sketch update path only supports those two encodings for string values; any other enum value reaches the default branch.","triggerScenarios":"An HLLSketchBuild aggregator spec carries a stringEncoding field with a value outside {UTF8, UTF16LE} — typically from a hand-edited native query JSON, a newer/older Druid version's enum name, or programmatic construction of the aggregator factory with a bad enum.","commonSituations":"Typos in JSON like 'utf-8' or 'utf8' if enum parsing allows other values; copying aggregator specs across Druid versions where the enum set changed; custom tooling generating aggregator specs with invalid encoding names.","solutions":["Set the aggregator's stringEncoding to exactly 'UTF8' or 'UTF16LE'.","Remove the stringEncoding field entirely to use the default (UTF8).","Validate query JSON against the Druid enum names for your Druid version."],"exampleFix":"// before\n{\"type\": \"HLLSketchBuild\", \"name\": \"s\", \"fieldName\": \"v\", \"stringEncoding\": \"utf-8\"}\n// after\n{\"type\": \"HLLSketchBuild\", \"name\": \"s\", \"fieldName\": \"v\", \"stringEncoding\": \"UTF8\"}","handlingStrategy":"validation","validationCode":"if (stringEncoding != null && !stringEncoding.equals(\"UTF8\") && !stringEncoding.equals(\"UTF16LE\")) throw new IllegalArgumentException(\"stringEncoding must be UTF8 or UTF16LE\");","typeGuard":"boolean validEncoding(StringEncoding e) { return e == StringEncoding.UTF8 || e == StringEncoding.UTF16LE; }","tryCatchPattern":"try { updateSketchWithString(sketch, enc, value); } catch (UOE e) { /* default to UTF8 and retry */ }","preventionTips":["Only set stringEncoding to UTF8 or UTF16LE","Omit stringEncoding to use the default","Validate aggregator spec JSON against the Druid version's enum set"],"tags":["datasketches","hll","enum","string-encoding"],"backgroundTag":"invalid-enum-value","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"}