apache/druid · error · IllegalArgumentException

Received a non-applicable rewrite

Error message

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

What it means

ArrayContainsElementFilter.rewriteRequiredColumns() rewrites the filter's column per a supplied columnRewrites map during query rewrite (e.g. for subtotals/join rewrites). If the map does not contain an entry for this filter's column, the rewrite is not applicable and Druid throws this IAE. Note the source passes columnRewrites twice as the format arg, so the message will show the map instead of the dimension.

Solutions

  1. Include an entry for the filter's column in the columnRewrites map before rewriting
  2. Only call rewriteRequiredColumns on filters whose column appears in the map; check map.containsKey(filter.getColumn()) first
  3. Use Filter.rewrite() semantics for optional rewrites if applicability is uncertain

Example fix

// before
filter.rewriteRequiredColumns(Map.of("otherCol", "newCol"));
// after
filter.rewriteRequiredColumns(Map.of(filter.getColumn(), "newCol"));
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

boolean applicable = columnRewrites != null && columnRewrites.containsKey(filter.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 (directly or via rewrite) with a map lacking a key equal to the filter's 'column' field.

Common situations: Applying a column-rewrite map built for a different filter/query; programmatically rewriting composite filters where only some sub-filters share the rewritten column.

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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/filter/ArrayContainsElementFilter.java:298

  @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 ArrayContainsElementFilter(
        rewriteDimensionTo,
        elementMatchValueType,
        elementMatchValue,
        filterTuning
    );
  }

  private static class ArrayContainsPredicateFactory implements DruidPredicateFactory
  {
    private final ExprEval<?> elementMatchValue;
    private final EqualityFilter.EqualityPredicateFactory equalityPredicateFactory;

View on GitHub (pinned to 9b90983fd2)