apache/druid · error · IllegalArgumentException

Cannot accept both 'splitPoints' and 'numBins'

Error message

Cannot accept both 'splitPoints' and 'numBins'

What it means

The KllDoublesSketchToHistogramPostAggregator constructor validates that 'splitPoints' (explicit bin edges) and 'numBins' (auto-generated bin count) are mutually exclusive. Supplying both is ambiguous, so it throws IllegalArgumentException at construction time. Exactly one (or neither, defaulting bins) must be provided.

Solutions

  1. Remove either 'splitPoints' or 'numBins' from the post-aggregator spec, keeping only one
  2. If you need explicit edges, delete numBins; if you want even bins, delete splitPoints
  3. In spec-builder code, only emit the second field when the first is null

Example fix

// before
{"type":"kllDoublesSketchToHistogram","name":"h","field":f,"splitPoints":[1.0,2.0],"numBins":10}
// after
{"type":"kllDoublesSketchToHistogram","name":"h","field":f,"splitPoints":[1.0,2.0]}
Defensive patterns

Strategy: validation

Validate before calling

Map<String,Object> spec = readSpec();
if (spec.containsKey("splitPoints") && spec.containsKey("numBins")) {
  throw new IllegalArgumentException("Provide only one of splitPoints and numBins");
}

Try / catch

try { new KllDoublesSketchToHistogramPostAggregator(name, field, sp, nb); } catch (IllegalArgumentException e) { log.error("Histogram spec invalid: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Constructing KllDoublesSketchToHistogramPostAggregator(name, field, splitPoints, numBins) with both arguments non-null — e.g. a JSON spec containing both "splitPoints": [...] and "numBins": 10.

Common situations: Copy-pasting a spec and adding numBins while forgetting to remove splitPoints; programmatic spec builders that set defaults for both fields; template-driven query generation.

Related errors


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

Appendix: source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchToHistogramPostAggregator.java:62

  private final String name;
  private final PostAggregator field;
  private final double[] splitPoints;
  private final Integer numBins;

  @JsonCreator
  public KllDoublesSketchToHistogramPostAggregator(
      @JsonProperty("name") final String name,
      @JsonProperty("field") final PostAggregator field,
      @JsonProperty("splitPoints") @Nullable final double[] splitPoints,
      @JsonProperty("numBins") @Nullable final Integer numBins)
  {
    this.name = Preconditions.checkNotNull(name, "name is null");
    this.field = Preconditions.checkNotNull(field, "field is null");
    this.splitPoints = splitPoints;
    this.numBins = numBins;
    if (splitPoints != null && numBins != null) {
      throw new IAE("Cannot accept both 'splitPoints' and 'numBins'");
    }
  }

  @Override
  public Object compute(final Map<String, Object> combinedAggregators)
  {
    final KllDoublesSketch sketch = (KllDoublesSketch) field.compute(combinedAggregators);
    final int numBins = this.splitPoints != null ? this.splitPoints.length + 1 :
        (this.numBins != null ? this.numBins.intValue() : DEFAULT_NUM_BINS);
    if (numBins < 2) {
      throw new IAE("at least 2 bins expected");
    }
    if (sketch.isEmpty()) {
      final double[] histogram = new double[numBins];
      Arrays.fill(histogram, Double.NaN);
      return histogram;
    }
    final double[] splitPoints;

View on GitHub (pinned to 9b90983fd2)