apache/druid · error · IAE

valueType[ ] is already set, cannot change to[ ]

Error message

valueType[%s] is already set, cannot change to[%s]

What it means

ColumnDescriptor.Builder guards against contradictory metadata while a segment column is serialized: once a valueType is set, calling setValueType with a different ValueType fails. This catches indexers disagreeing on a column's type (e.g. one part says STRING, another LONG).

Solutions

  1. Ensure all writers/mergers agree on the column's ValueType before building the descriptor (check input segment schemas)
  2. Remove the redundant setValueType call that conflicts with an earlier one
  3. Re-index/re-ingest segments that have inconsistent column types

Example fix

// before
builder.setValueType(ValueType.STRING);
// ... other code ...
builder.setValueType(ValueType.LONG); // IAE
// after
builder.setValueType(ValueType.LONG); // set once, consistently
Defensive patterns

Strategy: validation

Validate before calling

// Before building the descriptor, assert all inputs agree:
assert inputs.stream().map(s -> s.getValueType(col)).distinct().count() == 1;

Try / catch

try { builder.setValueType(t); } catch (IAE e) { throw new IllegalStateException("inconsistent column type across inputs", e); }

Prevention

When it happens

Trigger: Building a ColumnDescriptor (e.g. in IndexMerger/index generation paths like makeColumnDescriptor or makeMetricsColumns) where the value type is set twice with differing ValueTypes.

Common situations: Merging segments whose identical column has different ValueTypes; custom column serializers or extensions that set the type in two places; corrupted/merged schema metadata across segment versions.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/segment/column/ColumnDescriptor.java:148

    for (ColumnPartSerde part : parts) {
      part.getDeserializer().read(buffer, builder, columnConfig, parent);
    }
    return builder.build();
  }

  public static class Builder
  {
    @Nullable
    private ValueType valueType = null;
    @Nullable
    private Boolean hasMultipleValues = null;

    private final List<ColumnPartSerde> parts = new ArrayList<>();

    public Builder setValueType(ValueType valueType)
    {
      if (this.valueType != null && this.valueType != valueType) {
        throw new IAE("valueType[%s] is already set, cannot change to[%s]", this.valueType, valueType);
      }
      this.valueType = valueType;
      return this;
    }

    public Builder setHasMultipleValues(boolean hasMultipleValues)
    {
      if (this.hasMultipleValues != null && this.hasMultipleValues != hasMultipleValues) {
        throw new IAE(
            "hasMultipleValues[%s] is already set, cannot change to[%s]", this.hasMultipleValues, hasMultipleValues
        );
      }
      this.hasMultipleValues = hasMultipleValues;
      return this;
    }

    public Builder addSerde(ColumnPartSerde serde)
    {

View on GitHub (pinned to 9b90983fd2)