{"record":{"id":"db0b91ffdc379415","repo":"apache/iceberg","slug":"unsupported-table-change-dropconstraint-db0b91","errorCode":null,"errorMessage":"Unsupported table change: DropConstraint.","messagePattern":"Unsupported table change: DropConstraint\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/util/FlinkAlterTableUtil.java","lineNumber":147,"sourceCode":"        TableChange.ModifyColumn modifyColumn = (TableChange.ModifyColumn) change;\n        applyModifyColumn(pendingUpdate, modifyColumn);\n      } else if (change instanceof TableChange.DropColumn) {\n        TableChange.DropColumn dropColumn = (TableChange.DropColumn) change;\n        pendingUpdate.deleteColumn(dropColumn.getColumnName());\n      } else if (change instanceof TableChange.AddWatermark) {\n        throw new UnsupportedOperationException(\"Unsupported table change: AddWatermark.\");\n      } else if (change instanceof TableChange.ModifyWatermark) {\n        throw new UnsupportedOperationException(\"Unsupported table change: ModifyWatermark.\");\n      } else if (change instanceof TableChange.DropWatermark) {\n        throw new UnsupportedOperationException(\"Unsupported table change: DropWatermark.\");\n      } else if (change instanceof TableChange.AddUniqueConstraint) {\n        TableChange.AddUniqueConstraint addPk = (TableChange.AddUniqueConstraint) change;\n        applyUniqueConstraint(pendingUpdate, addPk.getConstraint());\n      } else if (change instanceof TableChange.ModifyUniqueConstraint) {\n        TableChange.ModifyUniqueConstraint modifyPk = (TableChange.ModifyUniqueConstraint) change;\n        applyUniqueConstraint(pendingUpdate, modifyPk.getNewConstraint());\n      } else if (change instanceof TableChange.DropConstraint) {\n        throw new UnsupportedOperationException(\"Unsupported table change: DropConstraint.\");\n      } else {\n        throw new UnsupportedOperationException(\"Cannot apply unknown table change: \" + change);\n      }\n    }\n  }\n\n  private static void applyAddColumn(UpdateSchema pendingUpdate, TableChange.AddColumn addColumn) {\n    Column flinkColumn = addColumn.getColumn();\n    Preconditions.checkArgument(\n        FlinkCompatibilityUtil.isPhysicalColumn(flinkColumn),\n        \"Unsupported table change: Adding computed column %s.\",\n        flinkColumn.getName());\n\n    Type icebergType = FlinkSchemaUtil.convert(flinkColumn.getDataType().getLogicalType());\n\n    if (flinkColumn.getDataType().getLogicalType().isNullable()) {\n      pendingUpdate.addColumn(\n          flinkColumn.getName(), icebergType, flinkColumn.getComment().orElse(null));","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/util/FlinkAlterTableUtil.java#L129-L165","documentation":"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.","triggerScenarios":"Executing 'ALTER TABLE ... DROP CONSTRAINT/PK' style statements routed to the Iceberg Flink catalog's alterTable implementation.","commonSituations":"Flink SQL workflows that manage primary keys on upsert-capable tables and attempt to remove a primary key constraint from an Iceberg table.","solutions":["Avoid dropping constraints on Iceberg tables; rebuild the table (create-as + backfill) without the constraint if removal is truly required.","Modify the constraint with MODIFY UNIQUE CONSTRAINT instead of dropping it when a change is needed.","Handle the change outside Flink DDL, e.g. by updating table metadata via Iceberg APIs if/when constraint removal is supported."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (changes.stream().anyMatch(c -> c instanceof TableChange.DropConstraint)) { throw new IllegalArgumentException('Dropping constraints is unsupported on Iceberg tables via Flink'); }","typeGuard":null,"tryCatchPattern":"try { catalog.alterTable(tableIdent, changes); } catch (UnsupportedOperationException e) { LOG.warn('Constraint drop rejected: {}', e.getMessage()); }","preventionTips":["Treat Iceberg primary keys as immutable; plan table rebuild for constraint removal","Use MODIFY UNIQUE CONSTRAINT for adjustments instead of drop+add","Audit DDL scripts for DROP CONSTRAINT statements before targeting Iceberg tables"],"tags":["flink","sql","schema-change","constraint","unsupported"],"backgroundTag":"operation-not-supported","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}