{"record":{"id":"86585728149ce0db","repo":"apache/druid","slug":"received-a-non-applicable-rewrite-s-filter-s-di-865857","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/EqualityFilter.java","lineNumber":295,"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 EqualityFilter(\n        rewriteDimensionTo,\n        matchValueType,\n        matchValue,\n        filterTuning\n    );\n  }\n\n  /**\n   * Can the match value type be cast directly to column type for equality comparison? For non-numeric match types, we\n   * just use exact string equality regardless of the column type. For numeric match value types against string columns,\n   * we instead cast the string to the match value type number for matching equality.","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/filter/EqualityFilter.java#L277-L313","documentation":"EqualityFilter.rewriteRequiredColumns() rewrites the filter's equality column based on a columnRewrites map. When the map has no entry for this filter's column, the rewrite cannot be applied and Druid throws this IAE. The source mistakenly passes columnRewrites twice as format args, so the reported 'dimension' shows the map.","triggerScenarios":"Invoking rewriteRequiredColumns on an EqualityFilter with a map missing the key matching the filter's column field.","commonSituations":"Join/subtotal query rewrites where the rewrite map was built against different column names; nested filter trees where only some equality filters reference the rewritten column.","solutions":["Ensure the rewrite map contains a mapping for the equality filter's column","Check columnRewrites.containsKey(filter.getColumn()) before calling rewriteRequiredColumns","Build the map from the filter tree's actual columns rather than assuming fixed names"],"exampleFix":"// before\nMap.of(\"channel\", \"channel_renamed\") // filter's column is \"page\"\n// after\nMap.of(\"page\", \"page_renamed\")","handlingStrategy":"validation","validationCode":"if (!columnRewrites.containsKey(equalityFilter.getColumn())) {\n  throw new IllegalArgumentException(\"rewrite map missing column: \" + equalityFilter.getColumn());\n}","typeGuard":"boolean applicable = columnRewrites != null && columnRewrites.containsKey(equalityFilter.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":["Derive rewrite maps by scanning all filters for their columns","Keep rewrite maps in sync with datasource schema changes","Unit-test rewriteRequiredColumns with each filter type"],"tags":["filter","query-rewrite","equality-filter"],"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-17T20:17:13.540Z"}