apache/druid · error · ISE

Invalid input [ ] of type [ ] for [ ] aggregator [ ]

Error message

Invalid input [%s] of type [%s] for [%s] aggregator [%s]

What it means

HllSketchBuildAggregatorFactory.validateInputs throws IllegalStateException when the input column's capabilities report ValueType.COMPLEX, i.e. the field already contains serialized HLL sketches. Building a new sketch from an already-sketch column is invalid; use the merge-type aggregator (HllSketchMergeFactory) for that. It is invoked while factorizing vectorized/SQL aggregators.

Solutions

  1. Switch the aggregator type from HLLSketchBuild to HLLSketchMerge when the input column already holds sketches.
  2. Point the build aggregator at the raw string/numeric column that should be sketched.
  3. Fix ingestion spec so the source column stored is raw data, not a serialized sketch, if raw building is intended.
  4. In SQL use APPROX_COUNT_DISTINCT_DS_HLL on raw values and DS_HLL(...) on sketch columns appropriately.

Example fix

// before
{"type": "HLLSketchBuild", "name": "s", "fieldName": "sketch_col"}
// after
{"type": "HLLSketchMerge", "name": "s", "fieldName": "sketch_col"}
Defensive patterns

Strategy: validation

Validate before calling

ColumnCapabilities caps = columnCapabilities(fieldName); if (caps != null && caps.is(ValueType.COMPLEX) && factory.getType().equals("HLLSketchBuild")) { throw new IllegalArgumentException("use HLLSketchMerge for sketch columns"); }

Type guard

boolean isComplexColumn = caps != null && caps.is(ValueType.COMPLEX);

Try / catch

try { factory.factorize(...) } catch (ISE e) { /* switch to HLLSketchMerge */ }

Prevention

When it happens

Trigger: Configuring an HLLSketchBuild aggregator whose fieldName points to a COMPLEX column (e.g. an HLLSketch-typed column produced by ingestion or another sketch), during query factorizeVector or formulateSketchUpdater.

Common situations: Mistakenly using 'HLLSketchBuild' on a column ingested as sketch (should be 'HLLSketchMerge'); copying a query spec that had sketch output columns and feeding them back as build inputs; schema drift after switching ingestion to store sketches.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchBuildAggregatorFactory.java:155

  @Override
  public AggregatorFactory withName(String newName)
  {
    return new HllSketchBuildAggregatorFactory(
        newName,
        getFieldName(),
        getLgK(),
        getTgtHllType(),
        getStringEncoding(),
        isShouldFinalize(),
        isRound()
    );
  }

  private void validateInputs(@Nullable ColumnCapabilities capabilities)
  {
    if (capabilities != null) {
      if (capabilities.is(ValueType.COMPLEX)) {
        throw new ISE(
            "Invalid input [%s] of type [%s] for [%s] aggregator [%s]",
            getFieldName(),
            capabilities.asTypeString(),
            HllSketchModule.BUILD_TYPE_NAME,
            getName()
        );
      }
    }
  }

  private HllSketchUpdater formulateSketchUpdater(ColumnSelectorFactory columnSelectorFactory)
  {
    final ColumnCapabilities capabilities = columnSelectorFactory.getColumnCapabilities(getFieldName());
    validateInputs(capabilities);

    HllSketchUpdater updater = null;
    if (capabilities != null &&
        StringEncoding.UTF8.equals(getStringEncoding()) && ValueType.STRING.equals(capabilities.getType())) {

View on GitHub (pinned to 9b90983fd2)