apache/seatunnel · error · DatabendConnectorException

SQL_OPERATION_FAILED

SQL_OPERATION_FAILED

Error message

Failed to execute SQL: {sql}, error: {e.getMessage()}

What it means

executeSql wraps any SQLException from running a raw SQL statement on a Databend connection, including the offending SQL text in the message. Used for CDC setup statements (creating raw tables, streams) and other auxiliary SQL. The cause retains the driver error.

Source

Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSink.java:205

                            databendCatalog,
                            tablePath,
                            catalogTable,
                            customSql));
        } catch (Exception e) {
            throw new DatabendConnectorException(
                    DatabendConnectorErrorCode.CONNECT_FAILED,
                    "Failed to create SaveModeHandler: " + e.getMessage(),
                    e);
        }
    }

    private boolean executeSql(Connection connection, String sql) {
        try (java.sql.Statement statement = connection.createStatement()) {
            log.info("Executing SQL: {}", sql);
            statement.execute(sql);
            return true;
        } catch (SQLException e) {
            throw new DatabendConnectorException(
                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
                    "Failed to execute SQL: " + sql + ", error: " + e.getMessage(),
                    e);
        }
    }

    /** Convert SeaTunnel data type to Databend data type */
    private String convertToDatabendType(SeaTunnelDataType<?> dataType) {
        switch (dataType.getSqlType()) {
            case STRING:
                return "STRING";
            case BOOLEAN:
                return "BOOLEAN";
            case TINYINT:
                return "TINYINT";
            case SMALLINT:
                return "SMALLINT";
            case INT:

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Copy the SQL from the error message and run it directly in Databend to see the precise error
  2. Verify referenced tables/streams/databases exist and the user has required privileges
  3. Fix the custom SQL or CDC configuration that generated the failing statement
  4. Check Databend server version compatibility for the SQL used (e.g. STREAM support)
Defensive patterns

Strategy: try-catch

Try / catch

try {
    // job execution
} catch (DatabendConnectorException e) {
    if (e.getErrorCode() == DatabendConnectorErrorCode.SQL_OPERATION_FAILED
            && e.getMessage().startsWith("Failed to execute SQL")) {
        // parse the SQL from the message, fix and resubmit
    } else { throw e; }
}

Prevention

When it happens

Trigger: Any statement executed via DatabendSink.executeSql fails server-side — syntax error, missing object, insufficient privileges, or connection drop.

Common situations: CDC infrastructure DDL (CREATE TABLE/STREAM) referencing a missing database; user lacking CREATE privileges; invalid custom SQL from config; Databend dialect differences.

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/24b204317ea07c4a. Report an issue: GitHub.