apache/druid · error · IllegalArgumentException

Received a non-applicable rewrite

Error message

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

What it means

RangeFilter.rewriteRequiredColumns() rewrites the range filter's column from a columnRewrites map. When the map does not contain the filter's column, the rewrite is non-applicable and Druid throws this IAE including the map and the filter's column (this source correctly passes 'column' as the second arg).

Solutions

  1. Add the RangeFilter's column mapping to the columnRewrites map before rewriting
  2. Guard with columnRewrites.containsKey(filter.getColumn()) prior to the call
  3. Apply rewrites at the query level (Query.filter rewrite) so applicability is handled per-filter

Example fix

// before
rangeFilter.rewriteRequiredColumns(Map.of("other", "other2")); // filter column is "__time"
// after
rangeFilter.rewriteRequiredColumns(Map.of("__time", "__time_renamed"));
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

boolean applicable = columnRewrites != null && columnRewrites.containsKey(rangeFilter.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 RangeFilter with a columnRewrites map lacking the filter's column key.

Common situations: Range/time-bound filters in rewritten join or subtotal queries; rewrite maps generated for a subset of the query's columns.

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/17ff75bfbd6cb9bd. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/filter/RangeFilter.java:377

  @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,
          column
      );
    }
    return new RangeFilter(
        rewriteDimensionTo,
        matchValueType,
        lower,
        upper,
        lowerOpen,
        upperOpen,
        filterTuning
    );
  }

  public boolean isEquality()
  {

View on GitHub (pinned to 9b90983fd2)