{"record":{"id":"38db76a3c4cfd3ef","repo":"apache/seatunnel","slug":"data-type-cast-field","errorCode":"DATA_TYPE_CAST_FIELD","errorMessage":"Value type does not match column type  for column ","messagePattern":"Value type does not match column type  for column ","errorType":"error_code","errorClass":"KuduConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-kudu/src/main/java/org/apache/seatunnel/connectors/seatunnel/kudu/serialize/KuduRowSerializer.java","lineNumber":113,"sourceCode":"                        break;\n                    case TIMESTAMP:\n                        Object fieldValue = element.getField(columnIndex);\n                        if (fieldValue == null) {\n                            row.addObject(seaTunnelRowType.getFieldName(columnIndex), null);\n                        } else {\n                            LocalDateTime localDateTime = (LocalDateTime) fieldValue;\n                            row.addObject(\n                                    seaTunnelRowType.getFieldName(columnIndex),\n                                    java.sql.Timestamp.valueOf(localDateTime));\n                        }\n                        break;\n                    default:\n                        throw new KuduConnectorException(\n                                CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n                                \"Unsupported column type: \" + type.getSqlType());\n                }\n            } catch (ClassCastException e) {\n                throw new KuduConnectorException(\n                        KuduConnectorErrorCode.DATA_TYPE_CAST_FIELD,\n                        \"Value type does not match column type \"\n                                + type.getSqlType()\n                                + \" for column \"\n                                + seaTunnelRowType.getFieldName(columnIndex));\n            }\n        }\n    }\n}\n","sourceCodeStart":95,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-kudu/src/main/java/org/apache/seatunnel/connectors/seatunnel/kudu/serialize/KuduRowSerializer.java#L95-L123","documentation":"KuduRowSerializer catches a ClassCastException thrown while converting a SeaTunnelRow field value to the type required by the Kudu column, and rethrows it as a KuduConnectorException with code DATA_TYPE_CAST_FIELD. It means the SeaTunnel row field's runtime Java type does not correspond to the declared column SQL type (e.g. a String value in an INT column). The exception names the offending SQL type and column so the mismatch can be located quickly.","triggerScenarios":"serializeRow writes a SeaTunnelRow whose field at columnIndex cannot be cast to the Java class expected by the Kudu column type declared in the SeaTunnelRowType; e.g. the upstream transform produced a String where Kudu expects an Integer, or vice versa.","commonSituations":"Upstream source or transform emits different types than declared in the catalog schema; users map Kudu INT columns to string data; field ordering mismatch causes values to land in the wrong column type after schema changes; CSV/JSON sources reading all fields as strings feed directly into Kudu sink.","solutions":["Check the SeaTunnelRowType schema matches the actual runtime types of the values in the row; fix the upstream source/transform to emit correct types","Add a transform (e.g. FieldMapper/CDC type conversion) to cast fields to the expected type before the Kudu sink","Verify field order in your source matches the Kudu table column order or use explicit column mapping","Log the row and rowType at DEBUG to identify which field value has the wrong class"],"exampleFix":"// before: value emitted as String \"123\" for INT column\nrow = new SeaTunnelRow(new Object[]{\"123\"});\n// after: convert to Integer in transform or source\nrow = new SeaTunnelRow(new Object[]{Integer.parseInt(\"123\")});","handlingStrategy":"validation","validationCode":"for (int i = 0; i < rowType.getTotalFields(); i++) {\n    Object v = row.getField(i);\n    if (v != null && !expectedJavaClass(rowType.getFieldType(i)).isInstance(v)) {\n        throw new IllegalStateException(\"Field \" + rowType.getFieldName(i) + \" has wrong type: \" + v.getClass());\n    }\n}","typeGuard":"boolean matches(SeaTunnelRowType t, int i, Object v) {\n    return v == null || expectedJavaClass(t.getFieldType(i)).isInstance(v);\n}","tryCatchPattern":"try {\n    serializer.serializeRow(row);\n} catch (KuduConnectorException e) {\n    if (KuduConnectorErrorCode.DATA_TYPE_CAST_FIELD.equals(e.getErrorCode())) {\n        // fix upstream typing or coerce field, then retry\n    } else throw e;\n}","preventionTips":["Declare SeaTunnelRowType field types identical to the Kudu table schema","Insert explicit cast/mapping transforms between source and Kudu sink","Test with a sample row before full pipeline runs","Watch for sources that read all fields as strings (CSV/JSON)"],"tags":["type-mismatch","kudu","serialization"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}