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

MySqlUtils.readTableSplitDataStatement builds the JDBC PreparedStatement that reads one snapshot chunk (with start/end key parameters) and wraps any Exception during statement construction into a RuntimeException with this message. It throws when bind parameters, SQL text, or driver interaction fail while assembling the chunk-read statement, with the original exception as the cause.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlUtils.java:318

            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 SeaTunnelRowType getSplitType(
            Table table, RelationalDatabaseConnectorConfig dbzConnectorConfig) {
        List<Column> primaryKeys = table.primaryKeyColumns();
        if (primaryKeys.isEmpty()) {
            throw new SeaTunnelException(
                    String.format(
                            "Incremental snapshot for tables requires primary key,"
                                    + " but table %s doesn't have primary key.",
                            table.id()));
        }

        // use first field in primary key as the split key
        return getSplitType(primaryKeys.get(0), dbzConnectorConfig);
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the cause of the RuntimeException to see which bind/type failed and check the primary key column types
  2. Avoid unsupported/exotic PK column types, or add the table's primary key as a supported type (e.g. convert unsigned bigint handling)
  3. Re-run the snapshot so splits are re-planned against the current table schema
  4. Verify the table schema did not change (PK dropped/altered) between planning and reading
Defensive patterns

Strategy: validation

Validate before calling

// confirm PK column types are driver-bindable before snapshot
ResultSet rs = st.executeQuery(
    "SELECT data_type FROM information_schema.columns " +
    "WHERE table_schema=DATABASE() AND table_name='t' AND column_key='PRI'");

Try / catch

try {
    PreparedStatement ps = MySqlUtils.readTableSplitDataStatement(jdbc, query, splitStart, splitEnd, pkNum);
} catch (RuntimeException e) {
    // inspect e.getCause() for the bind failure
}

Prevention

When it happens

Trigger: Calling readTableSplitDataStatement when setObject binding fails for the split-key values (e.g. value type unsupported by the driver), the split key array is null/shorter than the primary key count, or the SQL string is malformed after quoting.

Common situations: Exotic primary-key column types (e.g. unsigned bigint, spatial) whose values the driver can't bind via setObject; primary key columns removed by concurrent DDL so splitEnd arrays mismatch; corrupted split metadata from a prior planning bug.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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