apache/seatunnel · error · JdbcConnectorException
DATA_TYPE_CAST_FAILED
DATA_TYPE_CAST_FAILED
Error message
error field:
What it means
InceptorJdbcRowConverter.toExternal wraps per-field conversion in a catch-all: any exception while binding a field is rethrown as JdbcConnectorException(DATA_TYPE_CAST_FAILED) naming the offending field ('error field:<fieldName>'). It indicates the field's value could not be converted to the JDBC parameter type.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/inceptor/InceptorJdbcRowConverter.java:151
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
- Inspect the field named in the message and fix the source data or cast it to the target column type before sinking.
- Add a transform step to coerce types (e.g. string-to-int with validation) before the Inceptor sink.
- Align the declared SeaTunnel schema with the actual Inceptor table column types.
Example fix
// before
source field: age = "twenty" (INT column)
// after
transform { plugin_name = "FieldMapper" } # or fix upstream data: age = 20 Defensive patterns
Strategy: try-catch
Validate before calling
// coerce & check field values against declared types before writing
Object v = row.getField(i);
if (rowType.getFieldType(i).getSqlType() == SqlType.INT && !(v instanceof Integer)) throw new IllegalArgumentException("field '" + rowType.getFieldNames()[i] + "' must be INT, got: " + v); Type guard
boolean isAssignable(SeaTunnelRowType rt, int i, Object v) { try { /* compare v's class to rt.getFieldType(i) expectation */ return v == null || expectedClass(rt.getFieldType(i)).isInstance(v); } catch (Exception e) { return false; } } Try / catch
try { converter.toExternal(schema, dbSchema, row, ps); } catch (JdbcConnectorException e) { if (e.getErrorCode() == JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED) { log.error("bad field: {}", e.getMessage()); /* skip/quarantine the row */ } else throw e; } Prevention
- Align SeaTunnel schema types with actual Inceptor table columns
- Cleanse/validate upstream data before the sink
- Add per-row error handling to quarantine bad rows instead of failing the job
When it happens
Trigger: Any runtime exception during value conversion in toExternal (type cast failure, null handling, format mismatch) for the field at fieldIndex in the row being written to Inceptor.
Common situations: Data values that don't match declared types (e.g. string 'abc' into an INT column), timezone/date parsing problems, or upstream connector emitting values incompatible with the Inceptor column types.
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
- UNSUPPORTED_DATA_TYPE
- UNSUPPORTED_DATA_TYPE
- CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE
- JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED
- The jdbc url format is incorrect: ${url}
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/108786518120db00.
Report an issue: GitHub.