apache/druid · error · org.apache.druid.java.util.common.IAE

Illegal probability[%s], must be strictly between 0 and 1

Error message

Illegal probability[%s], must be strictly between 0 and 1

What it means

The QuantilePostAggregator constructor validates that the probability is strictly between 0 and 1 and throws IllegalArgumentException otherwise. A quantile is undefined outside (0,1), so invalid constructor arguments are rejected immediately at query-spec parsing time.

Source

Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/QuantilePostAggregator.java:58

public class QuantilePostAggregator extends ApproximateHistogramPostAggregator
{
  // this doesn't need to handle nulls because the values come from ApproximateHistogram
  static final Comparator COMPARATOR = Comparator.comparingDouble(o -> ((Number) o).doubleValue());

  private final float probability;

  @JsonCreator
  public QuantilePostAggregator(
      @JsonProperty("name") String name,
      @JsonProperty("fieldName") String fieldName,
      @JsonProperty("probability") float probability
  )
  {
    super(name, fieldName);
    this.probability = probability;

    if (probability < 0 || probability > 1) {
      throw new IAE("Illegal probability[%s], must be strictly between 0 and 1", probability);
    }
  }

  @Override
  public Comparator getComparator()
  {
    return COMPARATOR;
  }

  @Override
  public Set<String> getDependentFields()
  {
    return Sets.newHashSet(fieldName);
  }

  @Override
  public Object compute(Map<String, Object> values)
  {

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Set probability to a value strictly between 0 and 1, e.g. 0.5 or 0.95.
  2. If converting from percent, divide by 100 and clamp away from the bounds (0 and 100 percent are invalid).
  3. Add validation upstream before building the query spec.

Example fix

// before
{"type": "quantile", "fieldName": "h", "probability": 1.0}
// after
{"type": "quantile", "fieldName": "h", "probability": 0.99}
Defensive patterns

Strategy: validation

Validate before calling

if (!(probability > 0 && probability < 1)) {
  throw new IllegalArgumentException("probability must be strictly between 0 and 1, got " + probability);
}

Type guard

boolean isValidProbability(double p) {
  return p > 0.0 && p < 1.0;
}

Try / catch

try {
  QuantilePostAggregator q = new QuantilePostAggregator(name, fieldName, probability);
} catch (IllegalArgumentException e) {
  // clamp/correct probability and retry
}

Prevention

When it happens

Trigger: Constructing QuantilePostAggregator programmatically or via JSON with probability <= 0 or >= 1 (including NaN outside range checks like Infinity), e.g. probability: 1.0 or 0.

Common situations: Hand-written query JSON using 0.5f mis-typed, generated specs computing probability as a ratio that can hit 0 or 1, or config-driven percentiles where 0 and 100 were not converted to 0.x fractions.

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