{"record":{"id":"3176cd0ba3b48bfe","repo":"apache/seatunnel","slug":"unsupported-constraint-type-3176cd","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/oceanbase/OceanBaseMysqlCreateTableSqlBuilder.java","lineNumber":279,"sourceCode":"        switch (constraintType) {\n            case INDEX_KEY:\n                keyName = \"KEY\";\n                break;\n            case UNIQUE_KEY:\n                keyName = \"UNIQUE KEY\";\n                break;\n            case FOREIGN_KEY:\n                keyName = \"FOREIGN KEY\";\n                // todo:\n                break;\n            case VECTOR_INDEX_KEY:\n                keyName = \"VECTOR INDEX\";\n                return String.format(\n                                \"%s `%s` (%s)\",\n                                keyName, constraintKey.getConstraintName(), indexColumns)\n                        + \" WITH (distance=L2, type=hnsw)\";\n            default:\n                throw new UnsupportedOperationException(\n                        \"Unsupported constraint type: \" + constraintType);\n        }\n        return String.format(\n                \"%s `%s` (%s)\", keyName, constraintKey.getConstraintName(), indexColumns);\n    }\n}\n","sourceCodeStart":261,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/oceanbase/OceanBaseMysqlCreateTableSqlBuilder.java#L261-L286","documentation":"buildConstraintKeySql in OceanBaseMysqlCreateTableSqlBuilder throws UnsupportedOperationException when a TableConstraint has a constraint type the OceanBase MySQL-mode DDL builder does not handle (the switch's default branch). The builder only supports PRIMARY KEY, UNIQUE, and VECTOR INDEX constraint kinds; anything else cannot be translated to OceanBase DDL.","triggerScenarios":"Generating CREATE TABLE SQL for an OceanBase MySQL catalog table whose TableSchema contains a constraint of an unhandled type (e.g. CHECK constraints, foreign keys, or a new constraint kind added to the API but not to this builder).","commonSituations":"Syncing schemas from MySQL/other catalogs that carry CHECK or FOREIGN KEY constraints into OceanBase via the JDBC catalog; using a newer SeaTunnel API version whose constraint enum grew without this builder being updated.","solutions":["Remove unsupported constraints (CHECK/FK) from the TableSchema before calling the OceanBase catalog createTable","Add a case for the missing constraint type in buildConstraintKeySql, emitting equivalent OceanBase DDL or skipping it with a log warning","Update to a SeaTunnel version where the OceanBase builder supports the constraint type"],"exampleFix":"// before\nTableSchema schema = tableSchema with TableConstraint.check(...);\ncatalog.createTable(path, table, false); // throws\n// after\nschema.getTableConstraints().removeIf(c -> c.getConstraintType() != ConstraintType.PRIMARY_KEY && c.getConstraintType() != ConstraintType.UNIQUE);\ncatalog.createTable(path, TableIdentifier.of(path, schema), false);","handlingStrategy":"validation","validationCode":"// before createTable\nboolean hasUnsupported = schema.getTableConstraints().stream()\n    .map(TableConstraint::getConstraintType)\n    .anyMatch(t -> t != ConstraintType.PRIMARY_KEY && t != ConstraintType.UNIQUE);\nif (hasUnsupported) { throw new IllegalArgumentException(\"OceanBase MySQL builder supports only PK/UNIQUE constraints\"); }","typeGuard":"boolean isSupportedConstraint(TableConstraint c) {\n    ConstraintType t = c.getConstraintType();\n    return t == ConstraintType.PRIMARY_KEY || t == ConstraintType.UNIQUE;\n}","tryCatchPattern":null,"preventionTips":["Strip CHECK/FK constraints from schemas destined for OceanBase MySQL mode","Keep the builder's switch in sync with the constraint enum; add tests per constraint type","Prefer expressing business rules as data validation in the pipeline instead of DB CHECK constraints"],"tags":["unsupported-operation","jdbc","oceanbase","ddl"],"backgroundTag":"unsupported-operation","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"}