apache/iceberg · error · UnsupportedOperationException
Unsupported table change: DropConstraint.
Error message
Unsupported table change: DropConstraint.
What it means
Flink's SQL ALTER TABLE path in FlinkAlterTableUtil.applySchemaChanges does not support dropping a named constraint (primary key or unique key) from an Iceberg table. When a TableChange.DropConstraint arrives, the utility throws UnsupportedOperationException because UpdateSchema has no counterpart operation for removing identifier-field/constraint definitions. Dropping constraints must be done through other means (e.g. UpdateSchema.setIdentifierFields with no fields).
Source
Thrown at flink/v2.2/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
- Avoid DROP CONSTRAINT DDL in Flink; instead use Table.updateSchema().setIdentifierFields() to redefine or clear identifier fields
- Clear the primary key by setting identifier fields to an empty set via a custom catalog call or job instead of a SQL change
- Handle UnsupportedOperationException in the Flink alter path and translate to a clear user-facing message that constraint drops are unsupported
Example fix
// before ALTER TABLE iceberg_table DROP PRIMARY KEY; // after Table table = catalog.loadTable(tableIdentifier); table.updateSchema().setIdentifierFields(ImmutableList.of()).commit();
Defensive patterns
Strategy: validation
Validate before calling
boolean dropsConstraint = changes.stream().anyMatch(c -> c instanceof TableChange.DropConstraint);
if (dropsConstraint) { throw new IllegalArgumentException("Constraint drops unsupported by Iceberg Flink catalog; use updateSchema().setIdentifierFields()"); } Type guard
boolean isDroppable = change instanceof TableChange.DropConstraint; // route separately
if (isDroppable) { handleConstraintDropManually(table); return; } Try / catch
try { FlinkAlterTableUtil.applySchemaChanges(update, changes); }
catch (UnsupportedOperationException e) {
if (e.getMessage().contains("DropConstraint")) { /* apply setIdentifierFields fallback */ }
else throw e;
} Prevention
- Never emit DROP CONSTRAINT DDL against Iceberg tables in Flink
- Manage identifier fields explicitly via Table.updateSchema()
- Review migration scripts from other engines for constraint operations before running them on Iceberg
When it happens
Trigger: Executing ALTER TABLE ... DROP PRIMARY KEY (or any DROP CONSTRAINT) against an Iceberg table via the Flink catalog, which routes the change into applySchemaChanges.
Common situations: Users migrating DDL from engines where constraint drops are routine (MySQL/Postgres/Spark) to Flink + Iceberg; schema evolution scripts that remove keys; framework-generated DDL that manages constraints declaratively.
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
- Cannot apply unknown table change:
- The given table change is not a property change:
- Cannot apply unknown modify-column change:
- Cannot apply unknown modify-column-position change:
- Cannot apply unknown unique constraint:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/01295e63273ae6a7.
Report an issue: GitHub.