{"record":{"id":"108786518120db00","repo":"apache/seatunnel","slug":"data-type-cast-failed-108786","errorCode":"DATA_TYPE_CAST_FAILED","errorMessage":"error field:","messagePattern":"error field:","errorType":"error_code","errorClass":"JdbcConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/inceptor/InceptorJdbcRowConverter.java","lineNumber":151,"sourceCode":"                        if (SqlType.TINYINT.equals(elementType.getSqlType())) {\n                            Short[] shortArray = new Short[array.length];\n                            for (int i = 0; i < array.length; i++) {\n                                shortArray[i] = Short.valueOf(array[i].toString());\n                            }\n                            statement.setObject(statementIndex, shortArray);\n                        } else {\n                            statement.setObject(statementIndex, array);\n                        }\n                        break;\n                    case MAP:\n                    case ROW:\n                    default:\n                        throw new JdbcConnectorException(\n                                CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n                                \"Unexpected value: \" + seaTunnelDataType);\n                }\n            } catch (Exception e) {\n                throw new JdbcConnectorException(\n                        JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED,\n                        \"error field:\" + rowType.getFieldNames()[fieldIndex],\n                        e);\n            }\n        }\n        return statement;\n    }\n}\n","sourceCodeStart":133,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/inceptor/InceptorJdbcRowConverter.java#L133-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nsource field: age = \"twenty\"  (INT column)\n// after\ntransform { plugin_name = \"FieldMapper\" }  # or fix upstream data: age = 20","handlingStrategy":"try-catch","validationCode":"// coerce & check field values against declared types before writing\nObject v = row.getField(i);\nif (rowType.getFieldType(i).getSqlType() == SqlType.INT && !(v instanceof Integer)) throw new IllegalArgumentException(\"field '\" + rowType.getFieldNames()[i] + \"' must be INT, got: \" + v);","typeGuard":"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; } }","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["jdbc","inceptor","data-type-cast","row-converter"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}