apache/seatunnel · error · org.apache.seatunnel.common.exception.SeaTunnelRuntimeException

COMMON-17

COMMON-17

Error message

'<identifier>' unsupported convert type '<dataType>' of '<field>' to SeaTunnel data type.

What it means

DB2 JDBC dialect failed to map a DB2 column type to a SeaTunnel data type. DB2TypeConverter.convert switches on the DB2 type name; when the type is not in its supported set it throws CommonError.convertToSeaTunnelTypeError with dialect DB_2, the raw db2Type string, and the column name from typeDefine.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/db2/DB2TypeConverter.java:223

                builder.sourceType(String.format("%s(%d)", DB2_BLOB, typeDefine.getLength()));
                builder.columnLength(typeDefine.getLength());
                builder.dataType(PrimitiveByteArrayType.INSTANCE);
                break;
            case DB2_DATE:
                builder.sourceType(DB2_DATE);
                builder.dataType(LocalTimeType.LOCAL_DATE_TYPE);
                break;
            case DB2_TIME:
                builder.sourceType(DB2_TIME);
                builder.dataType(LocalTimeType.LOCAL_TIME_TYPE);
                break;
            case DB2_TIMESTAMP:
                builder.sourceType(String.format("%s(%d)", DB2_TIMESTAMP, typeDefine.getScale()));
                builder.dataType(LocalTimeType.LOCAL_DATE_TIME_TYPE);
                builder.scale(typeDefine.getScale());
                break;
            default:
                throw CommonError.convertToSeaTunnelTypeError(
                        DatabaseIdentifier.DB_2, db2Type, typeDefine.getName());
        }
        return builder.build();
    }

    @Override
    public BasicTypeDefine reconvert(Column column) {
        BasicTypeDefine.BasicTypeDefineBuilder builder =
                BasicTypeDefine.builder()
                        .name(column.getName())
                        .nullable(column.isNullable())
                        .comment(column.getComment())
                        .defaultValue(column.getDefaultValue());
        switch (column.getDataType().getSqlType()) {
            case BOOLEAN:
                builder.columnType(DB2_BOOLEAN);
                builder.dataType(DB2_BOOLEAN);
                break;

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Cast or exclude the unsupported column in your source SQL (e.g. CAST(xml_col AS VARCHAR(...)))
  2. Upgrade SeaTunnel to a version whose DB2 converter supports the type
  3. Add a case for the missing DB2 type in DB2TypeConverter.convert and rebuild

Example fix

// before
SELECT id, doc FROM db2admin.t; -- doc is XML
// after
SELECT id, CAST(doc AS VARCHAR(32000)) AS doc FROM db2admin.t;
Defensive patterns

Strategy: validation

Validate before calling

Set<String> supported = Set.of("SMALLINT","INTEGER","BIGINT","DECIMAL","REAL","DOUBLE","CHAR","VARCHAR","DATE","TIME","TIMESTAMP");
for (Column c : tableColumns) {
    if (!supported.contains(c.getTypeName().toUpperCase())) {
        log.warn("DB2 column {} type {} unsupported - cast or exclude", c.getName(), c.getTypeName());
    }
}

Try / catch

try {
    return db2Converter.convert(column);
} catch (SeaTunnelRuntimeException e) {
    if (CommonErrorCode.CONVERT_TO_SEATUNNEL_TYPE_ERROR_SIMPLE.equals(e.getSeaTunnelErrorCode())) {
        log.warn("Falling back to STRING for DB2 column {}", column.getName());
        return StringType.STRING_TYPE;
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling DB2TypeConverter.convert(Column) (via JdbcTypeConverter) for a table whose column type string matches no case (e.g. XML, DECFLOAT, BLOB/CLOB in some versions, user-defined types).

Common situations: Reading DB2 tables containing LOB/XML/spatial columns; DB2 version upgrades introducing new built-in types; catalogs listing system tables with unusual column types.

Related errors


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