apache/seatunnel · error · JdbcConnectorException
JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED
JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED
Error message
error field:${fieldName} What it means
OceanBaseMysqlJdbcRowConverter.toExternal wraps any exception raised while setting a field on the PreparedStatement and rethrows it as JdbcConnectorException with DATA_TYPE_CAST_FAILED, identifying the failing field name. It indicates the SeaTunnel value could not be converted/bound to the target JDBC column type.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oceanbase/OceanBaseMysqlJdbcRowConverter.java:271
if (SqlType.TINYINT.equals(elementType.getSqlType())) {
Short[] shortArray = new Short[array.length];
for (int i = 0; i < array.length; i++) {
shortArray[i] = Short.valueOf(array[i].toString());
}
statement.setObject(statementIndex, shortArray);
} else {
statement.setObject(statementIndex, array);
}
break;
case MAP:
case ROW:
default:
throw new JdbcConnectorException(
CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,
"Unexpected value: " + seaTunnelDataType);
}
} catch (Exception e) {
throw new JdbcConnectorException(
JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED,
"error field:" + rowType.getFieldNames()[fieldIndex],
e);
}
}
return statement;
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Fix the field named in the message: align source schema type with the OceanBase column type.
- Insert a transform to cast/cleanse the offending field before the sink.
- Alter the table column to a type that can hold the source values (e.g. BIGINT/DECIMAL, wider VARCHAR).
- Inspect the cause exception (wrapped as cause) for the exact conversion failure.
Example fix
// before
source field: age STRING ("thirty") -> column age INT
// after
Transform: cast(age as INT) with validation/default, or change column to VARCHAR Defensive patterns
Strategy: validation
Validate before calling
// Validate value fits target column before writing
if (value instanceof String && targetColumnIsNumeric) {
Long.parseLong((String) value); // throws early with field context
} Try / catch
catch (JdbcConnectorException e) { if (e.getSeaTunnelApiErrorCode() == JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED) { log.error("Cast failed for field {}", e.getMessage()); } } Prevention
- Align source field types with OceanBase column types in the catalog
- Add transform casts/cleansing for mismatched fields before the sink
- Check the wrapped cause exception for the exact conversion problem
When it happens
Trigger: During toExternal, converting a field value (rowType.getFieldNames()[fieldIndex]) throws — e.g. a String that is not a valid number for an INT column, an out-of-range value for the column type, or an incompatible object passed to a setter.
Common situations: Source data contains values that don't fit the OceanBase column types (oversized numbers, bad date strings); a cast rule mismatch between source schema and table schema; nulls handled where the converter expects a value.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED
- Unsupported constraint type:
- Failed to querySQLResult
- Failed listing database in catalog %s
- TABLE_ALREADY_EXISTED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/f64dfb2cd061c7ce.
Report an issue: GitHub.