{"record":{"id":"6766555c4d9ad808","repo":"apache/seatunnel","slug":"add-batch-data-failed","errorCode":"ADD_BATCH_DATA_FAILED","errorMessage":"ADD_BATCH_DATA_FAILED","messagePattern":"ADD_BATCH_DATA_FAILED","errorType":"error_code","errorClass":"CassandraConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java","lineNumber":131,"sourceCode":"        }\n    }\n\n    private void addIntoBatch(SeaTunnelRow row, BoundStatement boundStatement) {\n        try {\n            for (int i = 0; i < cassandraParameters.getFields().size(); i++) {\n                String fieldName = cassandraParameters.getFields().get(i);\n                DataType dataType = tableSchema.get(i).getType();\n                Object fieldValue = row.getField(seaTunnelRowType.indexOf(fieldName));\n                boundStatement =\n                        TypeConvertUtil.reconvertAndInject(boundStatement, i, dataType, fieldValue);\n            }\n            if (cassandraParameters.getAsyncWrite()) {\n                completionStages.add(session.executeAsync(boundStatement));\n            } else {\n                boundStatementList.add(boundStatement);\n            }\n        } catch (Exception e) {\n            throw new CassandraConnectorException(\n                    CassandraConnectorErrorCode.ADD_BATCH_DATA_FAILED, e);\n        }\n    }\n\n    private String initPrepareCQL() {\n        String[] placeholder = new String[cassandraParameters.getFields().size()];\n        Arrays.fill(placeholder, \"?\");\n        return String.format(\n                \"INSERT INTO %s (%s) VALUES (%s)\",\n                cassandraParameters.getTable(),\n                String.join(\",\", cassandraParameters.getFields()),\n                String.join(\",\", placeholder));\n    }\n\n    @Override\n    public void close() throws IOException {\n        flush();\n        try {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java#L113-L149","documentation":"CassandraSinkWriter.addIntoBatch builds a BoundStatement from the SeaTunnel row and executes it (sync, or async added to completionStages). Any exception in that per-row conversion/execution path is wrapped as ADD_BATCH_DATA_FAILED. Note async write failures may surface later at flush, but binding/type-conversion errors throw here.","triggerScenarios":"Exception while creating/binding the prepared statement for a row — e.g. row field count or types don't match the configured fields, null handling issues, or synchronous execute throwing driver errors (invalid query, timeout, no nodes available).","commonSituations":"SeaTunnel schema field types incompatible with Cassandra column types (e.g. writing a string into an int column); number of configured fields differs from row arity; keyspace/table dropped mid-run; cluster node down.","solutions":["Align the sink's `fields` list and SeaTunnel schema types exactly with the Cassandra table columns (DESCRIBE TABLE and compare types).","Check getCause() of this exception for the driver's specific error (InvalidQuery, CodecNotFound, NoNodeAvailable) and address that.","Verify the table still exists and the prepared CQL matches the configured fields after any schema migration.","If timeouts/no-node errors occur, check cluster health, consistency level settings, and network between the SeaTunnel workers and Cassandra."],"exampleFix":"// before: row has 3 values, fields has 2 -> bind fails\nfields = [\"id\", \"name\"]\n// after: include all columns written by upstream\nfields = [\"id\", \"name\", \"age\"]","handlingStrategy":"validation","validationCode":"// assert row arity and types match fields config before writing\nassert row.size() == fields.size();","typeGuard":null,"tryCatchPattern":"// catch per-write failures and inspect the driver cause\ntry {\n    writer.write(row);\n} catch (CassandraConnectorException e) {\n    log.error(\"bind/execute failed: {}\", e.getCause(), e);\n    throw e;\n}","preventionTips":["Match sink fields list 1:1 with the upstream SeaTunnel schema columns.","Map SeaTunnel types to compatible Cassandra column types (string->text, int->int, etc.).","Avoid ALTER TABLE mid-run; restart jobs after schema changes."],"tags":["cassandra","write","type-mismatch","cql"],"backgroundTag":"database-write-failed","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"}