apache/druid · error · IAE

Column[%s] has conflicting types [%s] and [%s]

Error message

Column[%s] has conflicting types [%s] and [%s]

What it means

RowSignature's constructor validates that a column added multiple times carries a consistent type. When the same column name appears with two different (non-equal) ColumnTypes, Druid throws this IAE because a signature cannot resolve a single type per column. Note a null existing type is allowed; only genuinely conflicting non-null types fail.

Source

Thrown at processing/src/main/java/org/apache/druid/segment/column/RowSignature.java:78

   * {@link org.apache.druid.sql.calcite.schema.DruidSchema}
   * Also helps in comparing the RowSignatures in equals method
   */
  private final int hashCode;

  private RowSignature(final List<ColumnSignature> columnTypeList)
  {
    this.columnPositions.defaultReturnValue(-1);

    final ImmutableList.Builder<String> columnNamesBuilder = ImmutableList.builder();

    for (int i = 0; i < columnTypeList.size(); i++) {
      final ColumnSignature sig = columnTypeList.get(i);
      final ColumnType existingType = columnTypes.get(sig.name());

      if (columnTypes.containsKey(sig.name()) && !Objects.equals(existingType, sig.type())) {
        // It's ok to add the same column twice as long as the type is consistent.
        // Note: we need the containsKey because the existingType might be present, but null.
        throw new IAE("Column[%s] has conflicting types [%s] and [%s]", sig.name(), existingType, sig.type());
      }

      columnTypes.put(sig.name(), sig.type());
      columnPositions.put(sig.name(), i);
      columnNamesBuilder.add(sig.name());
    }

    this.columnNames = columnNamesBuilder.build();
    this.hashCode = computeHashCode();
  }

  @JsonCreator
  static RowSignature fromColumnSignatures(final List<ColumnSignature> columnSignatures)
  {
    final Builder builder = builder();

    for (final ColumnSignature columnSignature : columnSignatures) {
      builder.add(columnSignature.name(), columnSignature.type());

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Rename one of the conflicting columns (or cast one side with CAST in SQL) so both occurrences have the same type
  2. Inspect the signature-building code and ensure the column is only added once per type
  3. Check ingestion spec fields (timestampSpec.column, metricsSpec) for accidental reuse of one column name with different types

Example fix

// before
RowSignature.builder().add("v", ColumnType.LONG).add("v", ColumnType.STRING).build(); // IAE
// after
RowSignature.builder().add("v", ColumnType.STRING).add("v_str", ColumnType.STRING).build();
Defensive patterns

Strategy: validation

Validate before calling

// before building, check duplicates:
Map<String, ColumnType> seen = new HashMap<>();
for (ColumnSignature sig : signatures) {
  ColumnType prev = seen.putIfAbsent(sig.name(), sig.type());
  if (prev != null && !Objects.equals(prev, sig.type())) {
    throw new IllegalArgumentException("Column " + sig.name() + " has conflicting types");
  }
}

Try / catch

try {
  RowSignature sig = RowSignature.builder()....build();
} catch (IAE e) {
  LOG.warn(e, "Conflicting column types; casting one side");
  // rebuild signature with an explicit CAST applied to the offending column
}

Prevention

When it happens

Trigger: Building a RowSignature (or merging query signatures in join/union planning) where a column name is added twice with different ColumnTypes, e.g. via RowSignature.builder().add("col", LONG).add("col", STRING).build().

Common situations: SQL queries whose subqueries/joins produce a column with diverging inferred types; ingestion specs with timestampSpec/dataSchema referencing the same column with different types; combining signatures from heterogeneous segments.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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