{"record":{"id":"3e54204a9b54b53c","repo":"apache/druid","slug":"must-have-a-valid-non-null-aggregator-name-3e5420","errorCode":null,"errorMessage":"Must have a valid, non-null aggregator name","messagePattern":"Must have a valid, non-null aggregator name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java","lineNumber":118,"sourceCode":"      final String name,\n      final String fieldName,\n      @Nullable final Integer k\n  )\n  {\n    this(name, fieldName, k, null, DEFAULT_SHOULD_FINALIZE);\n  }\n\n  DoublesSketchAggregatorFactory(\n      final String name,\n      final String fieldName,\n      @Nullable final Integer k,\n      @Nullable final Long maxStreamLength,\n      @Nullable final Boolean shouldFinalize,\n      final byte cacheTypeId\n  )\n  {\n    if (name == null) {\n      throw new IAE(\"Must have a valid, non-null aggregator name\");\n    }\n    this.name = name;\n    if (fieldName == null) {\n      throw new IAE(\"Parameter fieldName must be specified\");\n    }\n    this.fieldName = fieldName;\n    this.k = k == null ? DEFAULT_K : k;\n    Util.checkIfIntPowerOf2(this.k, \"k\");\n    this.maxStreamLength = maxStreamLength == null ? DEFAULT_MAX_STREAM_LENGTH : maxStreamLength;\n    this.shouldFinalize = shouldFinalize == null ? DEFAULT_SHOULD_FINALIZE : shouldFinalize;\n    this.cacheTypeId = cacheTypeId;\n  }\n\n  @Override\n  public Aggregator factorize(final ColumnSelectorFactory metricFactory)\n  {\n    if (metricFactory.getColumnCapabilities(fieldName) != null\n        && metricFactory.getColumnCapabilities(fieldName).isNumeric()) {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java#L100-L136","documentation":"DoublesSketchAggregatorFactory (Apache Druid datasketches quantiles extension) validates its constructor arguments eagerly. The aggregator 'name' (the output column name) is required and cannot be null; the factory throws IllegalArgumentException immediately rather than failing later at query time. This guarantees every aggregator in a query spec has an addressable output name.","triggerScenarios":"Constructing a DoublesSketchAggregatorFactory with a null name via JSON (e.g. an aggregation entry missing the \"name\" field or set to null) or programmatically via the public constructor.","commonSituations":"Hand-written native JSON queries where the aggregation object omits \"name\"; SQL planner bugs or extension code building aggregators dynamically; deserializing a saved query spec that was truncated or hand-edited.","solutions":["Add a non-null \"name\" field to the aggregation spec in the query JSON","In code, pass a valid output name string as the first constructor argument","If building from SQL, check that the planner-assigned aggregator name is not being overwritten with null"],"exampleFix":"// before\n{\"type\":\"quantilesDoublesSketch\",\"fieldName\":\"value\",\"k\":128}\n// after\n{\"type\":\"quantilesDoublesSketch\",\"name\":\"sketch_agg\",\"fieldName\":\"value\",\"k\":128}","handlingStrategy":"validation","validationCode":"if (aggregationSpec.get(\"name\") == null || aggregationSpec.get(\"name\").toString().isEmpty()) {\n  throw new IllegalArgumentException(\"quantilesDoublesSketch aggregation requires a non-null 'name'\");\n}","typeGuard":"boolean hasName(Map<String,Object> agg) { return agg.get(\"name\") instanceof String && !((String) agg.get(\"name\")).isEmpty(); }","tryCatchPattern":null,"preventionTips":["Always include \"name\" in every aggregation spec","Validate query JSON against Druid's aggregator schema before submitting","When building aggregators in Java, pass literal non-null name strings"],"tags":["java","druid","aggregation","null-argument"],"backgroundTag":"missing-required-argument","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"}