apache/seatunnel · error · SQLException
Error executing DDL SQL:
Error message
Error executing DDL SQL:
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbDialect.java:377
case DM_NVARCHAR:
case DM_LONGVARCHAR:
case DM_CLOB:
case DM_TEXT:
case DM_LONG:
return true;
default:
return false;
}
}
private void executeDDL(Connection connection, List<String> ddlSQL) throws SQLException {
try (Statement statement = connection.createStatement()) {
for (String sql : ddlSQL) {
log.info("Executing DDL SQL: {}", sql);
statement.execute(sql);
}
} catch (SQLException e) {
throw new SQLException("Error executing DDL SQL: " + ddlSQL, e.getSQLState(), e);
}
}
private String buildColumnCommentSQL(TablePath tablePath, Column column) {
return String.format(
"COMMENT ON COLUMN %s.%s IS '%s'",
tableIdentifier(tablePath), quoteIdentifier(column.getName()), column.getComment());
}
private boolean columnIsNullable(Connection connection, TablePath tablePath, String column)
throws SQLException {
String selectColumnSQL =
"SELECT"
+ " NULLABLE FROM"
+ " ALL_TAB_COLUMNS c"
+ " WHERE c.owner = '"
+ tablePath.getSchemaName()
+ "'"View on GitHub (pinned to cf67b549a7)
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
Example fix
// before: column rename with incompatible type change ALTER TABLE sch.t MODIFY old_col NEWTYPE; // after: add new column, migrate, then drop, or use a compatible type ALTER TABLE sch.t ADD new_col COMPATIBLE_TYPE; UPDATE sch.t SET new_col = old_col; ALTER TABLE sch.t DROP COLUMN old_col;
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: check DDL privilege and object existence
try (ResultSet rs = conn.getMetaData().getTables(null, tablePath.getSchemaName(), tablePath.getTableName(), new String[]{"TABLE"})) {
if (!rs.next()) throw new IllegalStateException("Target table does not exist: " + tablePath);
} Try / catch
try {
dialect.applySchemaChange(connection, tablePath, change);
} catch (SQLException e) {
SQLException cause = e;
while (cause.getNextException() != null) cause = cause.getNextException();
log.error("DDL failed, SQLState={} vendorCode={}", cause.getSQLState(), cause.getErrorCode(), cause);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- Unsupported constraint type:
- Failed to alter table add column, SQL:
- DamengDB does not support modifying the TEXT type directly.
- SQL_OPERATION_FAILED
- SCHEMA_CHANGE_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/ff718677ffb1bbc3.
Report an issue: GitHub.