apache/druid · error · IAE

Duplicate output name[%s]

Error message

Duplicate output name[%s]

What it means

MovingAverageQuery.verifyOutputNames enforces that every dimension output name is unique across the query result signature. When two DimensionSpec entries resolve to the same output name, the constructor throws IllegalArgumentException with 'Duplicate output name'.

Source

Thrown at extensions-contrib/moving-average-query/src/main/java/org/apache/druid/query/movingaverage/MovingAverageQuery.java:167

          postProcFn,
          sequence -> Sequences.filter(sequence, MovingAverageQuery.this.havingSpec::eval)
      );
    }

    this.limitFn = postProcFn;
  }

  private static void verifyOutputNames(
      List<DimensionSpec> dimensions,
      List<AggregatorFactory> aggregators,
      List<PostAggregator> postAggregators
  )
  {

    final Set<String> outputNames = new HashSet<>();
    for (DimensionSpec dimension : dimensions) {
      if (!outputNames.add(dimension.getOutputName())) {
        throw new IAE("Duplicate output name[%s]", dimension.getOutputName());
      }
    }

    for (AggregatorFactory aggregator : aggregators) {
      if (!outputNames.add(aggregator.getName())) {
        throw new IAE("Duplicate output name[%s]", aggregator.getName());
      }
    }

    for (PostAggregator postAggregator : postAggregators) {
      if (!outputNames.add(postAggregator.getName())) {
        throw new IAE("Duplicate output name[%s]", postAggregator.getName());
      }
    }
  }

  /**
   * A private constructor that avoids all of the various state checks.  Used by the with*() methods where the checks

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Remove or rename the duplicate dimension so each DimensionSpec has a unique outputName
  2. Set a distinct outputName on the colliding DimensionSpec (e.g. new DimensionSpec(column, "alias", extractionFn))
  3. Deduplicate the dimensions list before constructing the query

Example fix

// before
"dimensions": ["country", {"type": "default", "dimension": "country", "outputName": "country"}]
// after
"dimensions": ["country", {"type": "default", "dimension": "region", "outputName": "region"}]
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (DimensionSpec d : dimensions) {
  if (!seen.add(d.getOutputName())) throw new IllegalArgumentException("Duplicate dimension: " + d.getOutputName());
}

Try / catch

try { MovingAverageQuery q = new MovingAverageQuery(...); } catch (IllegalArgumentException e) { log.error("Invalid query dimensions: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Constructing a MovingAverageQuery (via JSON or Java API) whose dimensions list contains two DimensionSpecs with the same getOutputName(), e.g. two specs on different columns both defaulting their output name to the column name or both using the same explicit outputName.

Common situations: Hand-written JSON queries where a dimension is listed twice, programmatic query building that appends dimensions without deduplication, or group-by dimensions where one spec's outputName collides with another (e.g. extraction specs sharing a default output name).

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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