{"record":{"id":"b7f07c4249bd5b87","repo":"apache/druid","slug":"cannot-accept-both-splitpoints-and-numbins-b7f07c","errorCode":null,"errorMessage":"Cannot accept both 'splitPoints' and 'numBins'","messagePattern":"Cannot accept both 'splitPoints' and 'numBins'","errorType":"validation","errorClass":"org.apache.druid.java.util.common.IAE","httpStatus":null,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchToHistogramPostAggregator.java","lineNumber":62,"sourceCode":"\n  private final String name;\n  private final PostAggregator field;\n  private final double[] splitPoints;\n  private final Integer numBins;\n\n  @JsonCreator\n  public DoublesSketchToHistogramPostAggregator(\n      @JsonProperty(\"name\") final String name,\n      @JsonProperty(\"field\") final PostAggregator field,\n      @JsonProperty(\"splitPoints\") @Nullable final double[] splitPoints,\n      @JsonProperty(\"numBins\") @Nullable final Integer numBins)\n  {\n    this.name = Preconditions.checkNotNull(name, \"name is null\");\n    this.field = Preconditions.checkNotNull(field, \"field is null\");\n    this.splitPoints = splitPoints;\n    this.numBins = numBins;\n    if (splitPoints != null && numBins != null) {\n      throw new IAE(\"Cannot accept both 'splitPoints' and 'numBins'\");\n    }\n  }\n\n  @Override\n  public Object compute(final Map<String, Object> combinedAggregators)\n  {\n    final DoublesSketch sketch = (DoublesSketch) field.compute(combinedAggregators);\n    final int numBins = this.splitPoints != null ? this.splitPoints.length + 1 :\n        (this.numBins != null ? this.numBins.intValue() : DEFAULT_NUM_BINS);\n    if (numBins < 2) {\n      throw new IAE(\"at least 2 bins expected\");\n    }\n    if (sketch.isEmpty()) {\n      final double[] histogram = new double[numBins];\n      Arrays.fill(histogram, Double.NaN);\n      return histogram;\n    }\n    final double[] splitPoints;","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchToHistogramPostAggregator.java#L44-L80","documentation":"DoublesSketchToHistogramPostAggregator can size the histogram either from explicit splitPoints or from a numBins count, but not both. The constructor validates this and throws IllegalArgumentException when both parameters are supplied, since the two would define conflicting bin boundaries.","triggerScenarios":"Constructing the post-aggregator (in JSON or Java) with both a 'splitPoints' array and a 'numBins' value set to non-null at the same time.","commonSituations":"Copy-pasting a spec and adding numBins while leaving splitPoints in place; programmatic spec building where both optional fields are populated from configuration.","solutions":["Remove 'splitPoints' if you want evenly spaced bins computed from numBins.","Remove 'numBins' if you want bins bounded by your explicit splitPoints.","Null out one of the two fields in the code path that builds the spec dynamically."],"exampleFix":"// before\n{\"type\":\"quantilesDoublesSketchToHistogram\",\"field\":{...},\"splitPoints\":[0.25,0.75],\"numBins\":10}\n// after\n{\"type\":\"quantilesDoublesSketchToHistogram\",\"field\":{...},\"splitPoints\":[0.25,0.75]}","handlingStrategy":"validation","validationCode":"if (spec.splitPoints != null && spec.numBins != null) { throw new IllegalArgumentException(\"Provide either splitPoints or numBins, not both\"); }","typeGuard":null,"tryCatchPattern":"try { new DoublesSketchToHistogramPostAggregator(name, field, splitPoints, numBins); } catch (IllegalArgumentException e) { /* drop numBins or splitPoints and retry */ }","preventionTips":["Validate spec JSON before submission.","When building specs from config, explicitly null out the unused parameter."],"tags":["druid","datasketches","invalid-argument","conflicting-parameters"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}