{"record":{"id":"24b204317ea07c4a","repo":"apache/seatunnel","slug":"sql-operation-failed-24b204","errorCode":"SQL_OPERATION_FAILED","errorMessage":"Failed to execute SQL: {sql}, error: {e.getMessage()}","messagePattern":"Failed to execute SQL: (.+?), error: (.+?)","errorType":"error_code","errorClass":"DatabendConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSink.java","lineNumber":205,"sourceCode":"                            databendCatalog,\n                            tablePath,\n                            catalogTable,\n                            customSql));\n        } catch (Exception e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.CONNECT_FAILED,\n                    \"Failed to create SaveModeHandler: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    private boolean executeSql(Connection connection, String sql) {\n        try (java.sql.Statement statement = connection.createStatement()) {\n            log.info(\"Executing SQL: {}\", sql);\n            statement.execute(sql);\n            return true;\n        } catch (SQLException e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,\n                    \"Failed to execute SQL: \" + sql + \", error: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    /** Convert SeaTunnel data type to Databend data type */\n    private String convertToDatabendType(SeaTunnelDataType<?> dataType) {\n        switch (dataType.getSqlType()) {\n            case STRING:\n                return \"STRING\";\n            case BOOLEAN:\n                return \"BOOLEAN\";\n            case TINYINT:\n                return \"TINYINT\";\n            case SMALLINT:\n                return \"SMALLINT\";\n            case INT:","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSink.java#L187-L223","documentation":"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.","triggerScenarios":"Any statement executed via DatabendSink.executeSql fails server-side — syntax error, missing object, insufficient privileges, or connection drop.","commonSituations":"CDC infrastructure DDL (CREATE TABLE/STREAM) referencing a missing database; user lacking CREATE privileges; invalid custom SQL from config; Databend dialect differences.","solutions":["Copy the SQL from the error message and run it directly in Databend to see the precise error","Verify referenced tables/streams/databases exist and the user has required privileges","Fix the custom SQL or CDC configuration that generated the failing statement","Check Databend server version compatibility for the SQL used (e.g. STREAM support)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    // job execution\n} catch (DatabendConnectorException e) {\n    if (e.getErrorCode() == DatabendConnectorErrorCode.SQL_OPERATION_FAILED\n            && e.getMessage().startsWith(\"Failed to execute SQL\")) {\n        // parse the SQL from the message, fix and resubmit\n    } else { throw e; }\n}","preventionTips":["Pre-create databases/tables the CDC DDL depends on","Grant CREATE privileges to the Databend sink user","Validate any custom_sql in a Databend console before use"],"tags":["databend","sql","sink","ddl"],"backgroundTag":"sql-query-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"}