apache/seatunnel · error · UnsupportedOperationException

Unsupported constraint type:

Error message

Unsupported constraint type: 

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/oceanbase/OceanBaseMysqlCreateTableSqlBuilder.java:279

        switch (constraintType) {
            case INDEX_KEY:
                keyName = "KEY";
                break;
            case UNIQUE_KEY:
                keyName = "UNIQUE KEY";
                break;
            case FOREIGN_KEY:
                keyName = "FOREIGN KEY";
                // todo:
                break;
            case VECTOR_INDEX_KEY:
                keyName = "VECTOR INDEX";
                return String.format(
                                "%s `%s` (%s)",
                                keyName, constraintKey.getConstraintName(), indexColumns)
                        + " WITH (distance=L2, type=hnsw)";
            default:
                throw new UnsupportedOperationException(
                        "Unsupported constraint type: " + constraintType);
        }
        return String.format(
                "%s `%s` (%s)", keyName, constraintKey.getConstraintName(), indexColumns);
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Remove unsupported constraints (CHECK/FK) from the TableSchema before calling the OceanBase catalog createTable
  2. Add a case for the missing constraint type in buildConstraintKeySql, emitting equivalent OceanBase DDL or skipping it with a log warning
  3. Update to a SeaTunnel version where the OceanBase builder supports the constraint type

Example fix

// before
TableSchema schema = tableSchema with TableConstraint.check(...);
catalog.createTable(path, table, false); // throws
// after
schema.getTableConstraints().removeIf(c -> c.getConstraintType() != ConstraintType.PRIMARY_KEY && c.getConstraintType() != ConstraintType.UNIQUE);
catalog.createTable(path, TableIdentifier.of(path, schema), false);
Defensive patterns

Strategy: validation

Validate before calling

// before createTable
boolean hasUnsupported = schema.getTableConstraints().stream()
    .map(TableConstraint::getConstraintType)
    .anyMatch(t -> t != ConstraintType.PRIMARY_KEY && t != ConstraintType.UNIQUE);
if (hasUnsupported) { throw new IllegalArgumentException("OceanBase MySQL builder supports only PK/UNIQUE constraints"); }

Type guard

boolean isSupportedConstraint(TableConstraint c) {
    ConstraintType t = c.getConstraintType();
    return t == ConstraintType.PRIMARY_KEY || t == ConstraintType.UNIQUE;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/3176cd0ba3b48bfe. Report an issue: GitHub.