{"record":{"id":"dffbabe64af5c3b0","repo":"apache/druid","slug":"parameter-fieldname-must-be-specified","errorCode":null,"errorMessage":"Parameter fieldName must be specified","messagePattern":"Parameter fieldName must be specified","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":68,"sourceCode":"  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) {\n        return new KllSketchNoOpAggregator<>(getEmptySketch());\n      }\n      return getBuildAggregator(selector);\n    }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllSketchAggregatorFactory.java#L50-L86","documentation":"The KLL aggregator factory requires a fieldName — the input column whose values feed the sketch. Without it the aggregator cannot know what to aggregate, so the constructor throws IAE when fieldName is null.","triggerScenarios":"Creating a KLL build/merge aggregator factory (or JSON spec) without the 'fieldName' property, e.g. {\"type\": \"KLL_FLOATS_SKETCH_BUILD\", \"name\": \"kll\"} with no fieldName.","commonSituations":"Copy-pasting an aggregation spec and deleting the fieldName, or building aggregators dynamically over columns where the column name resolved to null (e.g. missing dimension in the input schema).","solutions":["Add the \"fieldName\" property pointing at the input column containing floats or serialized sketches.","Verify the input column exists in the datasource/row schema with the expected name.","For merge aggregators, ensure fieldName references the column holding previously-built sketch objects."],"exampleFix":"// before\n{\"type\": \"KLL_FLOATS_SKETCH_BUILD\", \"name\": \"kll_sketch\"}\n\n// after\n{\"type\": \"KLL_FLOATS_SKETCH_BUILD\", \"name\": \"kll_sketch\", \"fieldName\": \"value_col\"}","handlingStrategy":"validation","validationCode":"if (aggSpec.getFieldName() == null) {\n  throw new IllegalArgumentException(\"Aggregator spec requires 'fieldName'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  AggregatorFactory factory = buildKllFactory(name, fieldName, k, maxStreamLength);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"fieldName\")) {\n    // resolve a default input column or fail fast with a clear message\n    throw new IllegalArgumentException(\"KLL aggregator needs a valid input column\");\n  } else throw e;\n}","preventionTips":["Always specify fieldName in KLL build/merge aggregator specs.","Confirm the referenced column exists in the input schema.","For merge aggregators, point fieldName at the sketch-bearing column."],"tags":["druid","datasketches","kll","aggregator","missing-field"],"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"}