{"record":{"id":"cf0c98db2261f796","repo":"apache/druid","slug":"received-a-non-applicable-rewrite-s-filter-s-di","errorCode":null,"errorMessage":"Received a non-applicable rewrite: %s, filter's dimension: %s","messagePattern":"Received a non-applicable rewrite: (.+?), filter's dimension: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/filter/ArrayContainsElementFilter.java","lineNumber":298,"sourceCode":"  @Override\n  public Set<String> getRequiredColumns()\n  {\n    return ImmutableSet.of(column);\n  }\n\n  @Override\n  public boolean supportsRequiredColumnRewrite()\n  {\n    return true;\n  }\n\n  @Override\n  public Filter rewriteRequiredColumns(Map<String, String> columnRewrites)\n  {\n    String rewriteDimensionTo = columnRewrites.get(column);\n\n    if (rewriteDimensionTo == null) {\n      throw new IAE(\n          \"Received a non-applicable rewrite: %s, filter's dimension: %s\",\n          columnRewrites,\n          columnRewrites\n      );\n    }\n\n    return new ArrayContainsElementFilter(\n        rewriteDimensionTo,\n        elementMatchValueType,\n        elementMatchValue,\n        filterTuning\n    );\n  }\n\n  private static class ArrayContainsPredicateFactory implements DruidPredicateFactory\n  {\n    private final ExprEval<?> elementMatchValue;\n    private final EqualityFilter.EqualityPredicateFactory equalityPredicateFactory;","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/filter/ArrayContainsElementFilter.java#L280-L316","documentation":"ArrayContainsElementFilter.rewriteRequiredColumns() rewrites the filter's column per a supplied columnRewrites map during query rewrite (e.g. for subtotals/join rewrites). If the map does not contain an entry for this filter's column, the rewrite is not applicable and Druid throws this IAE. Note the source passes columnRewrites twice as the format arg, so the message will show the map instead of the dimension.","triggerScenarios":"Calling rewriteRequiredColumns (directly or via rewrite) with a map lacking a key equal to the filter's 'column' field.","commonSituations":"Applying a column-rewrite map built for a different filter/query; programmatically rewriting composite filters where only some sub-filters share the rewritten column.","solutions":["Include an entry for the filter's column in the columnRewrites map before rewriting","Only call rewriteRequiredColumns on filters whose column appears in the map; check map.containsKey(filter.getColumn()) first","Use Filter.rewrite() semantics for optional rewrites if applicability is uncertain"],"exampleFix":"// before\nfilter.rewriteRequiredColumns(Map.of(\"otherCol\", \"newCol\"));\n// after\nfilter.rewriteRequiredColumns(Map.of(filter.getColumn(), \"newCol\"));","handlingStrategy":"validation","validationCode":"if (!columnRewrites.containsKey(arrayFilter.getColumn())) {\n  throw new IllegalArgumentException(\"rewrite map missing column: \" + arrayFilter.getColumn());\n}","typeGuard":"boolean applicable = columnRewrites != null && columnRewrites.containsKey(filter.getColumn());","tryCatchPattern":"try {\n  return filter.rewriteRequiredColumns(columnRewrites);\n} catch (IAE e) {\n  if (e.getMessage().contains(\"non-applicable rewrite\")) { return filter; }\n  throw e;\n}","preventionTips":["Build rewrite maps from every column in the filter tree","Test rewrites against representative filter combinations","Walk the filter tree and skip filters whose columns are not in the map"],"tags":["filter","query-rewrite","column-rewrite"],"backgroundTag":"invalid-argument-value","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"}