apache/druid · error · IllegalArgumentException

Received a non-applicable rewrite

Error message

Received a non-applicable rewrite: %s, filter's dimension: %s

What it means

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.

Solutions

  1. Add an entry to the columnRewrites map keyed by the filter's dimension before calling rewriteRequiredColumns
  2. Verify the filter tree only contains filters whose dimensions are covered by the rewrite map
  3. Log/inspect the map contents (it appears in the exception) to find the missing dimension key

Example fix

// before
Map<String, String> rewrites = ImmutableMap.of("oldCol", "newCol");
filter.rewriteRequiredColumns(rewrites); // throws if filter's dimension is "otherCol"
// after
Map<String, String> rewrites = ImmutableMap.of("oldCol", "newCol", "otherCol", "otherCol");
filter.rewriteRequiredColumns(rewrites);
Defensive patterns

Strategy: validation

Validate before calling

if (!columnRewrites.containsKey(filterDimension)) { throw new IllegalStateException("rewrite map missing dimension: " + filterDimension); }

Type guard

boolean applicable(Filter f, Map<String,String> m) { return m != null && m.containsKey(((SearchQueryFilter) f).getDimension()); }

Try / catch

try { return filter.rewriteRequiredColumns(rewrites); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Received a non-applicable rewrite")) { return filter; /* or skip rewrite */ } throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/771a89ef1cd92e6c. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/segment/filter/SearchQueryFilter.java:76

        filterTuning
    );

    this.query = query;
  }

  @Override
  public boolean supportsRequiredColumnRewrite()
  {
    return true;
  }

  @Override
  public Filter rewriteRequiredColumns(Map<String, String> columnRewrites)
  {
    String rewriteDimensionTo = columnRewrites.get(dimension);

    if (rewriteDimensionTo == null) {
      throw new IAE(
          "Received a non-applicable rewrite: %s, filter's dimension: %s",
          columnRewrites,
          dimension
      );
    }

    return new SearchQueryFilter(
        rewriteDimensionTo,
        query,
        extractionFn,
        filterTuning
    );
  }

  @Override
  public String toString()
  {
    return "SearchFilter{" +

View on GitHub (pinned to 9b90983fd2)