apache/iceberg · error · UnsupportedOperationException

Unsupported table change: DropConstraint.

Error message

Unsupported table change: DropConstraint.

What it means

applySchemaChanges supports adding/modifying unique constraints but not removing them: TableChange.DropConstraint throws UnsupportedOperationException. Iceberg's schema update via this Flink bridge has no counterpart for constraint removal.

Source

Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/util/FlinkAlterTableUtil.java:147

        TableChange.ModifyColumn modifyColumn = (TableChange.ModifyColumn) change;
        applyModifyColumn(pendingUpdate, modifyColumn);
      } else if (change instanceof TableChange.DropColumn) {
        TableChange.DropColumn dropColumn = (TableChange.DropColumn) change;
        pendingUpdate.deleteColumn(dropColumn.getColumnName());
      } else if (change instanceof TableChange.AddWatermark) {
        throw new UnsupportedOperationException("Unsupported table change: AddWatermark.");
      } else if (change instanceof TableChange.ModifyWatermark) {
        throw new UnsupportedOperationException("Unsupported table change: ModifyWatermark.");
      } else if (change instanceof TableChange.DropWatermark) {
        throw new UnsupportedOperationException("Unsupported table change: DropWatermark.");
      } else if (change instanceof TableChange.AddUniqueConstraint) {
        TableChange.AddUniqueConstraint addPk = (TableChange.AddUniqueConstraint) change;
        applyUniqueConstraint(pendingUpdate, addPk.getConstraint());
      } else if (change instanceof TableChange.ModifyUniqueConstraint) {
        TableChange.ModifyUniqueConstraint modifyPk = (TableChange.ModifyUniqueConstraint) change;
        applyUniqueConstraint(pendingUpdate, modifyPk.getNewConstraint());
      } else if (change instanceof TableChange.DropConstraint) {
        throw new UnsupportedOperationException("Unsupported table change: DropConstraint.");
      } else {
        throw new UnsupportedOperationException("Cannot apply unknown table change: " + change);
      }
    }
  }

  private static void applyAddColumn(UpdateSchema pendingUpdate, TableChange.AddColumn addColumn) {
    Column flinkColumn = addColumn.getColumn();
    Preconditions.checkArgument(
        FlinkCompatibilityUtil.isPhysicalColumn(flinkColumn),
        "Unsupported table change: Adding computed column %s.",
        flinkColumn.getName());

    Type icebergType = FlinkSchemaUtil.convert(flinkColumn.getDataType().getLogicalType());

    if (flinkColumn.getDataType().getLogicalType().isNullable()) {
      pendingUpdate.addColumn(
          flinkColumn.getName(), icebergType, flinkColumn.getComment().orElse(null));

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Avoid dropping constraints on Iceberg tables; rebuild the table (create-as + backfill) without the constraint if removal is truly required.
  2. Modify the constraint with MODIFY UNIQUE CONSTRAINT instead of dropping it when a change is needed.
  3. Handle the change outside Flink DDL, e.g. by updating table metadata via Iceberg APIs if/when constraint removal is supported.
Defensive patterns

Strategy: validation

Validate before calling

if (changes.stream().anyMatch(c -> c instanceof TableChange.DropConstraint)) { throw new IllegalArgumentException('Dropping constraints is unsupported on Iceberg tables via Flink'); }

Try / catch

try { catalog.alterTable(tableIdent, changes); } catch (UnsupportedOperationException e) { LOG.warn('Constraint drop rejected: {}', e.getMessage()); }

Prevention

When it happens

Trigger: Executing 'ALTER TABLE ... DROP CONSTRAINT/PK' style statements routed to the Iceberg Flink catalog's alterTable implementation.

Common situations: Flink SQL workflows that manage primary keys on upsert-capable tables and attempt to remove a primary key constraint from an Iceberg table.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/db0b91ffdc379415. Report an issue: GitHub.