apache/seatunnel · error · RuntimeException

Failed to build the split data read statement.

Error message

Failed to build the split data read statement.

What it means

readTableSplitDataStatement builds a PreparedStatement for reading a split's data using chunk bounds. Any exception during construction (bad parameter types, null split bounds, wrong column count) is rethrown as RuntimeException('Failed to build the split data read statement.') with the original cause attached.

Solutions

  1. Read the wrapped cause ('Caused by') for the actual failure
  2. Avoid LOB/BLOB/unsupported types as primary keys for incremental snapshot
  3. Re-run the job to rebuild split metadata if it was corrupted
  4. Verify the table schema hasn't changed mid-snapshot (column type changes)
  5. Use a supported PK type (integer, string, timestamp) for chunk splitting

Example fix

// before: LOB primary key
CREATE TABLE t (payload CLOB PRIMARY KEY ...);
// after: integer surrogate key
CREATE TABLE t (id INT PRIMARY KEY, payload CLOB ...);
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check split bound types are JDBC-bindable
for (Object v : splitStart) { if (v == null || v instanceof byte[] || v instanceof java.sql.Blob) throw new IllegalStateException("Unsupported PK bound type: " + v.getClass()); }

Try / catch

try { PreparedStatement ps = Db2Utils.readTableSplitDataStatement(...); } catch (RuntimeException e) { if ("Failed to build the split data read statement.".equals(e.getMessage())) { log.error("statement build failed", e.getCause()); } throw e; }

Prevention

When it happens

Trigger: statement.setObject with values incompatible with the split column types, null split start/end arrays, or a mismatch between the split's row type and the number of primary-key columns when binding chunk-bound parameters.

Common situations: Unsupported primary-key column types (e.g. binary/LOB keys) in the chunk bounds; schema drift between snapshot planning and reading; corrupt split metadata after checkpoint restore.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/d2788e701dec5855. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java:322

            if (isFirstSplit) {
                for (int i = 0; i < primaryKeyNum; i++) {
                    statement.setObject(i + 1, splitEnd[i]);
                    statement.setObject(i + 1 + primaryKeyNum, splitEnd[i]);
                }
            } else if (isLastSplit) {
                for (int i = 0; i < primaryKeyNum; i++) {
                    statement.setObject(i + 1, splitStart[i]);
                }
            } else {
                for (int i = 0; i < primaryKeyNum; i++) {
                    statement.setObject(i + 1, splitStart[i]);
                    statement.setObject(i + 1 + primaryKeyNum, splitEnd[i]);
                    statement.setObject(i + 1 + 2 * primaryKeyNum, splitEnd[i]);
                }
            }
            return statement;
        } catch (Exception e) {
            throw new RuntimeException("Failed to build the split data read statement.", e);
        }
    }

    public static Db2DatabaseSchema createDb2DatabaseSchema(
            Db2ConnectorConfig connectorConfig, Db2Connection connection) {
        TopicSelector<TableId> topicSelector = Db2TopicSelector.defaultSelector(connectorConfig);
        SchemaNameAdjuster schemaNameAdjuster = SchemaNameAdjuster.create();
        return new Db2DatabaseSchema(
                connectorConfig, schemaNameAdjuster, topicSelector, connection);
    }

    private static String getPrimaryKeyColumnsProjection(SeaTunnelRowType rowType) {
        StringBuilder sql = new StringBuilder();
        for (Iterator<String> fieldNamesIt = Arrays.stream(rowType.getFieldNames()).iterator();
                fieldNamesIt.hasNext(); ) {
            sql.append(quote(fieldNamesIt.next()));
            if (fieldNamesIt.hasNext()) {
                sql.append(" , ");

View on GitHub (pinned to cf67b549a7)