{"record":{"id":"aab32fee60c90fab","repo":"apache/iceberg","slug":"altering-partition-keys-is-not-supported-yet-aab32f","errorCode":null,"errorMessage":"Altering partition keys is not supported yet.","messagePattern":"Altering partition keys is not supported yet\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java","lineNumber":488,"sourceCode":"  private boolean isReservedProperty(String prop) {\n    return FlinkCreateTableOptions.LOCATION_KEY.equalsIgnoreCase(prop)\n        || FlinkCreateTableOptions.CONNECTOR_PROPS_KEY.equalsIgnoreCase(prop)\n        || FlinkCreateTableOptions.SRC_CATALOG_PROPS_KEY.equalsIgnoreCase(prop);\n  }\n\n  private static void validateTableSchemaAndPartition(CatalogTable ct1, CatalogTable ct2) {\n    if (!Objects.equals(ct1.getUnresolvedSchema(), ct2.getUnresolvedSchema())) {\n      throw new UnsupportedOperationException(\n          \"Altering schema is not supported in the old alterTable API. \"\n              + \"To alter schema, use the other alterTable API and provide a list of TableChange's.\");\n    }\n\n    validateTablePartition(ct1, ct2);\n  }\n\n  private static void validateTablePartition(CatalogTable ct1, CatalogTable ct2) {\n    if (!ct1.getPartitionKeys().equals(ct2.getPartitionKeys())) {\n      throw new UnsupportedOperationException(\"Altering partition keys is not supported yet.\");\n    }\n  }\n\n  /**\n   * This alterTable API only supports altering table properties.\n   *\n   * <p>Support for adding/removing/renaming columns cannot be done by comparing CatalogTable\n   * instances, unless the Flink schema contains Iceberg column IDs.\n   *\n   * <p>To alter columns, use the other alterTable API and provide a list of TableChange's.\n   *\n   * @param tablePath path of the table or view to be modified\n   * @param newTable the new table definition\n   * @param ignoreIfNotExists flag to specify behavior when the table or view does not exist: if set\n   *     to false, throw an exception, if set to true, do nothing.\n   * @throws CatalogException in case of any runtime exception\n   * @throws TableNotExistException if the table does not exist\n   */","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L470-L506","documentation":"Neither alterTable API currently supports changing a table's partition keys; validateTablePartition compares getPartitionKeys() of the old and new CatalogTable and throws UnsupportedOperationException on any difference. Partition spec changes require rewriting the table, which the alter path does not perform.","triggerScenarios":"Calling alterTable with a CatalogTable whose partition keys differ from the existing table's partition keys.","commonSituations":"Reapplying full DDL where partitioning changed; tooling that regenerates table definitions with a new partition strategy and pushes them through alterTable.","solutions":["Keep partition keys unchanged when calling alterTable","Drop and recreate the table with the desired partition spec if repartitioning is intended (mind data loss)","Perform partition-spec evolution directly on the Iceberg table (updatePartitionSpec) outside the Flink catalog alter API"],"exampleFix":"// before\ncatalog.alterTable(path, tableWithNewPartitionKeys, false);\n// after\ncatalog.alterTable(path, tableWithSamePartitionKeys, false); // or recreate table","handlingStrategy":"validation","validationCode":"if (!existing.getPartitionKeys().equals(newTable.getPartitionKeys())) {\n  throw new IllegalStateException(\"Partition keys cannot be changed via alterTable; recreate the table\");\n}","typeGuard":"null","tryCatchPattern":"try { catalog.alterTable(path, newTable, false); } catch (UnsupportedOperationException e) { /* recreate table or use Iceberg updatePartitionSpec */ }","preventionTips":["Keep partition keys identical in alter calls","Plan partition-spec changes as explicit drop/recreate or Iceberg spec evolution"],"tags":["flink","iceberg-catalog","partitioning","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}