apache/seatunnel · error · IllegalStateException

typeDefine size not match

Error message

typeDefine size not match

What it means

DataConverter.convert(T[], Column[], BiFunction) first validates that typeDefine and columnDefine arrays have equal length; each type definition must correspond to exactly one column. Unequal lengths indicate the converter-specific type metadata and the SeaTunnel schema were built from different sources, so it throws IllegalStateException.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/DataConverter.java:77

    }

    default Object[] convert(Column[] columnDefine, Function<Column[], Object[]> valueApply) {
        Object[] fields = valueApply.apply(columnDefine);
        if (fields.length != columnDefine.length) {
            throw new IllegalStateException("columnDefine size not match");
        }

        for (int i = 0; i < fields.length; i++) {
            fields[i] = convert(columnDefine[i], fields[i]);
        }
        return fields;
    }

    default Object[] convert(
            T[] typeDefine, Column[] columnDefine, BiFunction<T[], Column[], Object[]> valueApply) {
        boolean hasTypeDefine = typeDefine != null;
        if (hasTypeDefine && typeDefine.length != columnDefine.length) {
            throw new IllegalStateException("typeDefine size not match");
        }

        Object[] fields = valueApply.apply(typeDefine, columnDefine);
        if (fields.length != columnDefine.length) {
            throw new IllegalStateException("columnDefine size not match");
        }

        for (int i = 0; i < fields.length; i++) {
            fields[i] = convert(hasTypeDefine ? typeDefine[i] : null, columnDefine[i], fields[i]);
        }
        return fields;
    }

    default Object reconvert(T typeDefine, Column columnDefine, Object value) {
        return reconvert(typeDefine, value);
    }

    /**

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Regenerate typeDefine and columnDefine from the same schema snapshot
  2. Verify the length equality before calling convert
  3. Clear/rebuild cached catalog metadata after DDL changes

Example fix

// before
convert(typeDefines, columnDefines, apply); // 10 vs 11
// after
if (typeDefines.length != columnDefines.length) {
    throw new IllegalArgumentException("refresh schema: " + typeDefines.length + " vs " + columnDefines.length);
}
convert(typeDefines, columnDefines, apply);
Defensive patterns

Strategy: validation

Validate before calling

if (typeDefine != null && typeDefine.length != columnDefine.length) {
    throw new IllegalArgumentException("typeDefine/columnDefine length mismatch: " + typeDefine.length + " vs " + columnDefine.length);
}

Try / catch

try {
    Object[] out = dataConverter.convert(typeDefine, columnDefine, valueApply);
} catch (IllegalStateException e) {
    log.error("Converter type metadata out of sync with schema: {}", e.getMessage());
    throw e;
}

Prevention

When it happens

Trigger: Passing a T[] typeDefine array sized differently from the Column[] array, e.g. after columns were added/dropped in one but not the other.

Common situations: Schema evolution (ALTER TABLE) applied to the source but the connector's cached converter types were not refreshed; hand-built mismatched arrays in custom code.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/549bd892f5c1278e. Report an issue: GitHub.