{"record":{"id":"9beacb431b98bbdb","repo":"apache/seatunnel","slug":"common-sql-operation-failed","errorCode":"COMMON_SQL_OPERATION_FAILED","errorMessage":"Add row data into batch error","messagePattern":"Add row data into batch error","errorType":"error_code","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java","lineNumber":123,"sourceCode":"                intHolder.setValue(0);\n            }\n        }\n    }\n\n    @Override\n    public void abortPrepare() {}\n\n    @Override\n    public void close() throws IOException {\n        this.proxy.close();\n        flush();\n    }\n\n    private void addIntoBatch(SeaTunnelRow row, JdbcBatchStatementExecutor clickHouseStatement) {\n        try {\n            clickHouseStatement.addToBatch(row);\n        } catch (SQLException e) {\n            throw new ClickhouseConnectorException(\n                    CommonErrorCodeDeprecated.SQL_OPERATION_FAILED,\n                    \"Add row data into batch error\",\n                    e);\n        }\n    }\n\n    private void flush(JdbcBatchStatementExecutor clickHouseStatement) {\n        try {\n            clickHouseStatement.executeBatch();\n        } catch (Exception e) {\n            throw new ClickhouseConnectorException(\n                    CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                    \"Clickhouse execute batch statement error\",\n                    e);\n        }\n    }\n\n    private void flush() {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java#L105-L141","documentation":"Wraps a SQLException thrown while adding a SeaTunnelRow to the JDBC batch statement via JdbcBatchStatementExecutor.addToBatch. It usually means the row's values do not fit the prepared INSERT statement's schema (column count, types, or format).","triggerScenarios":"A row's field count differs from the INSERT placeholders, a value cannot be bound to the target column type, or the executor received a rowKind it cannot render; occurs in ClickhouseSinkWriter.addIntoBatch during write().","commonSituations":"Upstream schema changed after the writer was initialized (columns added/removed), nested/array types serialized unexpectedly, or table schema edited while the job runs.","solutions":["Compare the SeaTunnelRow schema with the ClickHouse table schema and align columns/types","Re-run schema evolution checks; restart the job so statements are re-prepared against the current schema","Inspect the wrapped SQLException cause for the exact column/type mismatch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate row arity/types against table schema before writing\nif (row.getArity() != expectedColumnCount)\n  throw new IllegalStateException(\"row arity \" + row.getArity() + \" != table columns \" + expectedColumnCount);","typeGuard":null,"tryCatchPattern":"try { writer.write(row); } catch (ClickhouseConnectorException e) {\n  if (e.getCode().equals(CommonErrorCodeDeprecated.SQL_OPERATION_FAILED)\n      && e.getMessage().contains(\"Add row data into batch error\")) {\n    log.error(\"schema mismatch\", e.getCause()); // re-prepare statements / DLQ row\n  }\n}","preventionTips":["Keep the SeaTunnel catalog schema in sync with the ClickHouse table","Add schema-change monitoring; restart jobs after DDL changes","Log the wrapped SQLException cause to identify the offending column"],"tags":["clickhouse","jdbc","batch-write","schema-mismatch"],"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-14T05:17:10.506Z"}