{"record":{"id":"ff718677ffb1bbc3","repo":"apache/seatunnel","slug":"error-executing-ddl-sql","errorCode":null,"errorMessage":"Error executing DDL SQL: ","messagePattern":"Error executing DDL SQL: ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbDialect.java","lineNumber":377,"sourceCode":"            case DM_NVARCHAR:\n            case DM_LONGVARCHAR:\n            case DM_CLOB:\n            case DM_TEXT:\n            case DM_LONG:\n                return true;\n            default:\n                return false;\n        }\n    }\n\n    private void executeDDL(Connection connection, List<String> ddlSQL) throws SQLException {\n        try (Statement statement = connection.createStatement()) {\n            for (String sql : ddlSQL) {\n                log.info(\"Executing DDL SQL: {}\", sql);\n                statement.execute(sql);\n            }\n        } catch (SQLException e) {\n            throw new SQLException(\"Error executing DDL SQL: \" + ddlSQL, e.getSQLState(), e);\n        }\n    }\n\n    private String buildColumnCommentSQL(TablePath tablePath, Column column) {\n        return String.format(\n                \"COMMENT ON COLUMN %s.%s IS '%s'\",\n                tableIdentifier(tablePath), quoteIdentifier(column.getName()), column.getComment());\n    }\n\n    private boolean columnIsNullable(Connection connection, TablePath tablePath, String column)\n            throws SQLException {\n        String selectColumnSQL =\n                \"SELECT\"\n                        + \"        NULLABLE FROM\"\n                        + \"        ALL_TAB_COLUMNS c\"\n                        + \"        WHERE c.owner = '\"\n                        + tablePath.getSchemaName()\n                        + \"'\"","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbDialect.java#L359-L395","documentation":"Thrown by DmdbDialect.executeDDL (called from applySchemaChange) when a DDL statement fails to execute against a DM (Dameng) database. It wraps the original SQLException, preserving its SQLState, and includes the full list of DDL statements being applied.","triggerScenarios":"applySchemaChange on a Dameng connection where any statement in ddlSQL fails — e.g. syntax errors in generated ALTER/COMMENT statements, insufficient privileges, or the target table/column not existing.","commonSituations":"Schema-evolution attempts adding/dropping/renaming columns on DM databases with wrong types; COMMENT ON statements with special characters in comments; user lacking DDL privileges; table name/schema casing mismatches.","solutions":["Read the wrapped cause SQLException and its SQLState to find the failing statement (each statement is logged at info level before execution)","Run the logged DDL SQL manually in the DM database to reproduce the error","Check the user has DDL privileges on the target schema/table","Fix the column type/comment causing the invalid DDL, then retry the schema change"],"exampleFix":"// before: column rename with incompatible type change\nALTER TABLE sch.t MODIFY old_col NEWTYPE;\n// after: add new column, migrate, then drop, or use a compatible type\nALTER TABLE sch.t ADD new_col COMPATIBLE_TYPE;\nUPDATE sch.t SET new_col = old_col;\nALTER TABLE sch.t DROP COLUMN old_col;","handlingStrategy":"try-catch","validationCode":"// Pre-flight: check DDL privilege and object existence\ntry (ResultSet rs = conn.getMetaData().getTables(null, tablePath.getSchemaName(), tablePath.getTableName(), new String[]{\"TABLE\"})) {\n    if (!rs.next()) throw new IllegalStateException(\"Target table does not exist: \" + tablePath);\n}","typeGuard":null,"tryCatchPattern":"try {\n    dialect.applySchemaChange(connection, tablePath, change);\n} catch (SQLException e) {\n    SQLException cause = e;\n    while (cause.getNextException() != null) cause = cause.getNextException();\n    log.error(\"DDL failed, SQLState={} vendorCode={}\", cause.getSQLState(), cause.getErrorCode(), cause);\n}","preventionTips":["Run the generated DDL in a DM client session first to validate syntax","Grant the connector user DDL privileges (ALTER/COMMENT) on the target schema","Avoid special characters (quotes) in comments or escape them per DM rules","Validate column type compatibility before schema-change operations"],"tags":["jdbc","ddl","schema-change","dameng"],"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"}