apache/druid · error · IllegalArgumentException

Received a non-applicable rewrite

Error message

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

What it means

NullFilter.rewriteRequiredColumns() rewrites the null-check column using a columnRewrites map. If the map has no entry for the filter's column, the rewrite cannot proceed and Druid throws this IAE. The source passes columnRewrites twice as format args, so the logged 'dimension' shows the map rather than the column.

Solutions

  1. Include the NullFilter's column as a key in columnRewrites
  2. Check containsKey before invoking rewriteRequiredColumns
  3. Rewrite the whole filter tree with Filter.rewrite so only applicable filters are transformed

Example fix

// before
nullFilter.rewriteRequiredColumns(Map.of("x", "y")); // filter column is "dim"
// after
nullFilter.rewriteRequiredColumns(Map.of("dim", "dim2"));
Defensive patterns

Strategy: validation

Validate before calling

if (!columnRewrites.containsKey(nullFilter.getColumn())) {
  throw new IllegalArgumentException("rewrite map missing column: " + nullFilter.getColumn());
}

Type guard

boolean applicable = columnRewrites != null && columnRewrites.containsKey(nullFilter.getColumn());

Try / catch

try {
  return filter.rewriteRequiredColumns(columnRewrites);
} catch (IAE e) {
  if (e.getMessage().contains("non-applicable rewrite")) { return filter; }
  throw e;
}

Prevention

When it happens

Trigger: Calling rewriteRequiredColumns on a NullFilter with a map missing the key for the filter's column field.

Common situations: IS NULL/IS NOT NULL filters inside rewritten queries (join/subtotal) whose column is absent from the rewrite map; composite rewrites covering only some filters.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/filter/NullFilter.java:181

  @Override
  public Set<String> getRequiredColumns()
  {
    return ImmutableSet.of(column);
  }

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

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

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

  @Override
  public boolean equals(Object o)
  {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    NullFilter that = (NullFilter) o;

View on GitHub (pinned to 9b90983fd2)