apache/druid · error · IllegalArgumentException

Comparing arrays of p values is not supported

Error message

Comparing arrays of p values is not supported

What it means

PostAggregator.getComparator() is used when Druid needs to order post-aggregated values (e.g. in an orderBy spec). The t-test post-aggregator outputs a double[] of p-values, which has no meaningful ordering defined, so it unconditionally throws IAE from getComparator().

Solutions

  1. Remove any orderBy/sort clause referencing the tTest post-aggregator
  2. Compute the t-test in a subquery, project the p-value as a column, then sort on that projected column
  3. If ordering is essential, apply the sort in application code after receiving results

Example fix

// before
queryBuilder.addOrderBy(new OrderByColumnSpec("ttestPValue"))
// after
// compute t-test in inner query, then sort on projected column in outer query
GroupByQuery outer = builder.innerQuery(...).addOrderBy(new OrderByColumnSpec("pValue"))
Defensive patterns

Strategy: try-catch

Validate before calling

if (orderByColumns.stream().anyMatch(c -> "tTestPValue".equals(c.getDimension()))) {
  throw new IllegalArgumentException("Sorting by tTest post-aggregator output is not supported");
}

Try / catch

try {
  return queryClient.run(query);
} catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().contains("Comparing arrays of p values")) {
    return runWithoutOrderBy(query, results -> sortPValuesInApp(results));
  }
  throw e;
}

Prevention

When it happens

Trigger: Any query or API path that calls getComparator() on an ArrayOfDoublesSketchTTestPostAggregator, e.g. ordering results by this post-aggregator in an OrderBySpec or using it in a topN dimension-spec sort.

Common situations: Users attempting to sort/limit results by t-test p-value directly; generic tooling that calls getComparator() on every post-aggregator in the spec.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregator.java:63

public class ArrayOfDoublesSketchTTestPostAggregator extends ArrayOfDoublesSketchMultiPostAggregator
{

  @JsonCreator
  public ArrayOfDoublesSketchTTestPostAggregator(
      @JsonProperty("name") final String name,
      @JsonProperty("fields") List<PostAggregator> fields
  )
  {
    super(name, fields);
    if (fields.size() != 2) {
      throw new IAE("Illegal number of fields[%d], must be 2", fields.size());
    }
  }

  @Override
  public Comparator<double[]> getComparator()
  {
    throw new IAE("Comparing arrays of p values is not supported");
  }

  @Override
  public double[] compute(final Map<String, Object> combinedAggregators)
  {
    final ArrayOfDoublesSketch sketch1 = (ArrayOfDoublesSketch) getFields().get(0).compute(combinedAggregators);
    final ArrayOfDoublesSketch sketch2 = (ArrayOfDoublesSketch) getFields().get(1).compute(combinedAggregators);
    if (sketch1.getNumValues() != sketch2.getNumValues()) {
      throw new IAE(
          "Sketches have different number of values: %d and %d",
          sketch1.getNumValues(),
          sketch2.getNumValues()
      );
    }

    final SummaryStatistics[] stats1 = getStats(sketch1);
    final SummaryStatistics[] stats2 = getStats(sketch2);

View on GitHub (pinned to 9b90983fd2)