{"record":{"id":"9c00a3f986d433e8","repo":"apache/seatunnel","slug":"unsupported-constraint-type","errorCode":null,"errorMessage":"Unsupported constraint type: ","messagePattern":"Unsupported constraint type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/dm/DamengCreateTableSqlBuilder.java","lineNumber":219,"sourceCode":"                                                \"\\\"%s\\\"\",\n                                                CatalogUtils.getFieldIde(\n                                                        constraintKeyColumn.getColumnName(),\n                                                        fieldIde)))\n                        .collect(Collectors.joining(\", \"));\n\n        String keyName;\n        switch (constraintType) {\n            case INDEX_KEY:\n                keyName = \"KEY\";\n                break;\n            case UNIQUE_KEY:\n                keyName = \"UNIQUE\";\n                break;\n            case FOREIGN_KEY:\n                keyName = \"FOREIGN KEY\";\n                break;\n            default:\n                throw new UnsupportedOperationException(\n                        \"Unsupported constraint type: \" + constraintType);\n        }\n\n        if (StringUtils.equals(keyName, \"UNIQUE\")) {\n            return \"CONSTRAINT \"\n                    + constraintName\n                    + \"_\"\n                    + randomSuffix\n                    + \" UNIQUE (\"\n                    + indexColumns\n                    + \")\";\n        }\n        return null;\n    }\n}\n","sourceCodeStart":201,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/dm/DamengCreateTableSqlBuilder.java#L201-L235","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nColumnConstraint check = new CheckConstraint(\"ck\", \"amount > 0\"); // unsupported for Dameng\n// after\n// create table without CHECK, then execute manually:\ncatalog.executeSql(tablePath, \"ALTER TABLE \\\"t\\\" ADD CONSTRAINT ck CHECK (amount > 0)\");","handlingStrategy":"validation","validationCode":"// Java\nboolean supported = table.getTableSchema().getConstraints().stream()\n        .allMatch(c -> c.getType() == ConstraintType.PRIMARY_KEY\n            || c.getType() == ConstraintType.UNIQUE\n            || c.getType() == ConstraintType.FOREIGN_KEY);","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n    String ddl = DamengCreateTableSqlBuilder.build(...);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Constraint unsupported for Dameng DDL: {}\", e.getMessage());\n    // rebuild schema without the constraint or create it manually afterwards\n}","preventionTips":["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"],"tags":["jdbc","dameng","ddl","unsupported-operation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}