{"record":{"id":"737e1e64902d3e7c","repo":"apache/druid","slug":"must-have-a-valid-non-null-aggregator-name","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/kll/KllSketchAggregatorFactory.java","lineNumber":64,"sourceCode":"  // Used for sketch size estimation.\n  public static final long DEFAULT_MAX_STREAM_LENGTH = 1_000_000_000;\n\n  private final String name;\n  private final String fieldName;\n  private final int k;\n  private final long maxStreamLength;\n  private final byte cacheTypeId;\n\n  KllSketchAggregatorFactory(\n      final String name,\n      final String fieldName,\n      @Nullable final Integer k,\n      @Nullable final Long maxStreamLength,\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    this.maxStreamLength = maxStreamLength == null ? DEFAULT_MAX_STREAM_LENGTH : maxStreamLength;\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()) {\n      final ColumnValueSelector<ValueType> selector = metricFactory.makeColumnValueSelector(fieldName);\n      if (selector instanceof NilColumnValueSelector) {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllSketchAggregatorFactory.java#L46-L82","documentation":"KllSketchAggregatorFactory's constructor validates its arguments up front: the aggregator output name must be non-null because every aggregator needs a name to expose its results in the query result row. A null name throws IAE at construction time (query parse/spec validation), before any data is processed.","triggerScenarios":"Constructing a KLL aggregator factory (KllFloatsSketchBuildAggregatorFactory, KllFloatsSketchMergeAggregatorFactory, or via JSON spec) with name = null, e.g. {\"type\": \"KLL_FLOATS_SKETCH_BUILD\", \"fieldName\": \"x\"} without a 'name' field in some programmatic paths.","commonSituations":"Building aggregator specs programmatically and forgetting the name key, or deserialization paths where the name field was omitted.","solutions":["Provide a non-null 'name' in the aggregator spec, matching the column name you want in results.","If using JSON ingestion/query specs, add the missing \"name\" field.","Validate aggregator factory parameters before constructing them in code."],"exampleFix":"// before\nnew KllFloatsSketchBuildAggregatorFactory(null, \"sketch_col\", null, null)\n\n// after\nnew KllFloatsSketchBuildAggregatorFactory(\"kll_sketch\", \"sketch_col\", null, null)","handlingStrategy":"validation","validationCode":"if (aggSpec.getName() == null) {\n  throw new IllegalArgumentException(\"Aggregator spec requires a non-null 'name'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  AggregatorFactory factory = buildKllFactory(name, fieldName, k, maxStreamLength);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"non-null aggregator name\")) {\n    // supply a default name and retry\n    factory = buildKllFactory(\"kll_sketch\", fieldName, k, maxStreamLength);\n  } else throw e;\n}","preventionTips":["Always set the 'name' field in aggregator specs.","Validate spec objects programmatically before construction.","Use builder patterns that enforce non-null names."],"tags":["druid","datasketches","kll","aggregator","null-argument"],"backgroundTag":"null-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"}