apache/seatunnel · error · UnsupportedOperationException
Unsupported constraint type:
Error message
Unsupported constraint type:
What it means
DamengCreateTableSqlBuilder.buildConstraintKeySql maps ConstraintType (PRIMARY_KEY, UNIQUE, FOREIGN_KEY) to SQL keywords; any other constraint type hits the default branch and throws UnsupportedOperationException with 'Unsupported constraint type: <type>'. Dameng DDL generation only supports these three constraint kinds.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/dm/DamengCreateTableSqlBuilder.java:219
"\"%s\"",
CatalogUtils.getFieldIde(
constraintKeyColumn.getColumnName(),
fieldIde)))
.collect(Collectors.joining(", "));
String keyName;
switch (constraintType) {
case INDEX_KEY:
keyName = "KEY";
break;
case UNIQUE_KEY:
keyName = "UNIQUE";
break;
case FOREIGN_KEY:
keyName = "FOREIGN KEY";
break;
default:
throw new UnsupportedOperationException(
"Unsupported constraint type: " + constraintType);
}
if (StringUtils.equals(keyName, "UNIQUE")) {
return "CONSTRAINT "
+ constraintName
+ "_"
+ randomSuffix
+ " UNIQUE ("
+ indexColumns
+ ")";
}
return null;
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Remove unsupported constraints (e.g. CHECK) from the table schema before creating in Dameng, or define them manually afterward
- Upgrade the connector to a version that supports the constraint type for Dameng
- Extend DamengCreateTableSqlBuilder to handle the needed constraint type
- Catch UnsupportedOperationException during table creation and fall back to creating the table without constraints
Example fix
// before
ColumnConstraint check = new CheckConstraint("ck", "amount > 0"); // unsupported for Dameng
// after
// create table without CHECK, then execute manually:
catalog.executeSql(tablePath, "ALTER TABLE \"t\" ADD CONSTRAINT ck CHECK (amount > 0)"); Defensive patterns
Strategy: validation
Validate before calling
// Java
boolean supported = table.getTableSchema().getConstraints().stream()
.allMatch(c -> c.getType() == ConstraintType.PRIMARY_KEY
|| c.getType() == ConstraintType.UNIQUE
|| c.getType() == ConstraintType.FOREIGN_KEY); Try / catch
// Java
try {
String ddl = DamengCreateTableSqlBuilder.build(...);
} catch (UnsupportedOperationException e) {
LOG.warn("Constraint unsupported for Dameng DDL: {}", e.getMessage());
// rebuild schema without the constraint or create it manually afterwards
} Prevention
- Strip CHECK or other unsupported constraints before generating Dameng DDL
- Re-apply unsupported constraints manually via ALTER TABLE after table creation
- When upgrading SeaTunnel, verify new ConstraintType values are supported by the Dameng builder
When it happens
Trigger: Building CREATE TABLE SQL for a Dameng table whose CatalogTable defines a constraint type outside PRIMARY_KEY/UNIQUE/FOREIGN_KEY (e.g. CHECK constraints or future enum values).
Common situations: Source tables carrying constraint metadata (e.g. from another JDBC catalog) that Dameng's SQL builder cannot translate; new ConstraintType enum values added upstream without Dameng support.
Related errors
- Unsupported constraint type:
- %s (%s) type doesn't have a mapping to the SQL database colu
- Error executing DDL SQL:
- DamengDB does not support modifying the TEXT type directly.
- Table 'TablePath{databaseName='null', schemaName='null', tab
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/9c00a3f986d433e8.
Report an issue: GitHub.