{"record":{"id":"771a89ef1cd92e6c","repo":"apache/druid","slug":"received-a-non-applicable-rewrite-s-filter-s-di-771a89","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/segment/filter/SearchQueryFilter.java","lineNumber":76,"sourceCode":"        filterTuning\n    );\n\n    this.query = query;\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(dimension);\n\n    if (rewriteDimensionTo == null) {\n      throw new IAE(\n          \"Received a non-applicable rewrite: %s, filter's dimension: %s\",\n          columnRewrites,\n          dimension\n      );\n    }\n\n    return new SearchQueryFilter(\n        rewriteDimensionTo,\n        query,\n        extractionFn,\n        filterTuning\n    );\n  }\n\n  @Override\n  public String toString()\n  {\n    return \"SearchFilter{\" +","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/filter/SearchQueryFilter.java#L58-L94","documentation":"SearchQueryFilter.rewriteRequiredColumns throws this IllegalArgumentException when the supplied columnRewrites map has no entry for the filter's dimension. Rewriting a filter to target a different column only makes sense if the map covers the dimension this filter matches on; a missing key means the rewrite is not applicable to this filter instance. The library treats applying an inapplicable rewrite as a caller bug.","triggerScenarios":"Calling filter.rewriteRequiredColumns(Map<String,String>) with a map that omits the key equal to the SearchQueryFilter's dimension (e.g. rewriting a filter tree where only some dimensions are mapped).","commonSituations":"Query rewrites that rename or remap some columns but not all; filter trees built programmatically where the rewrite map was constructed for a different dimension set; partial rewrites after subquery pushdown.","solutions":["Add an entry to the columnRewrites map keyed by the filter's dimension before calling rewriteRequiredColumns","Verify the filter tree only contains filters whose dimensions are covered by the rewrite map","Log/inspect the map contents (it appears in the exception) to find the missing dimension key"],"exampleFix":"// before\nMap<String, String> rewrites = ImmutableMap.of(\"oldCol\", \"newCol\");\nfilter.rewriteRequiredColumns(rewrites); // throws if filter's dimension is \"otherCol\"\n// after\nMap<String, String> rewrites = ImmutableMap.of(\"oldCol\", \"newCol\", \"otherCol\", \"otherCol\");\nfilter.rewriteRequiredColumns(rewrites);","handlingStrategy":"validation","validationCode":"if (!columnRewrites.containsKey(filterDimension)) { throw new IllegalStateException(\"rewrite map missing dimension: \" + filterDimension); }","typeGuard":"boolean applicable(Filter f, Map<String,String> m) { return m != null && m.containsKey(((SearchQueryFilter) f).getDimension()); }","tryCatchPattern":"try { return filter.rewriteRequiredColumns(rewrites); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Received a non-applicable rewrite\")) { return filter; /* or skip rewrite */ } throw e; }","preventionTips":["Build the rewrite map from the filter tree's own dimension set, not from a hand-written list","Include identity mappings (dim -> dim) for dimensions that are not renamed"],"tags":["java","filter","column-rewrite"],"backgroundTag":"missing-required-argument","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"}