{"record":{"id":"d0083b595cf7bdf7","repo":"apache/iceberg","slug":"altering-partition-keys-is-not-supported-yet-d0083b","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.3/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.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L470-L506","documentation":"An UnsupportedOperationException from validateTablePartition thrown when an alterTable attempt changes the table's partition keys. Iceberg tables in this Flink catalog do not support altering partitioning via alterTable.","triggerScenarios":"Calling alterTable (legacy or TableChange-based, which also calls validateTablePartition) with a CatalogTable whose getPartitionKeys() differ from the existing table's partition keys.","commonSituations":"Attempting ALTER TABLE to add/drop partition columns; regenerating a CatalogTable with a different PARTITIONED BY clause and passing it to alterTable; migration tooling that rewrites partition specs.","solutions":["Do not change partition keys via alterTable; keep the partition spec unchanged.","To change partitioning, create a new table with the desired spec and migrate data (e.g. INSERT INTO ... SELECT), or evolve the partition spec using Iceberg's core API outside this Flink catalog path.","Verify the replacement CatalogTable preserves ct.getPartitionKeys().equals(existing.getPartitionKeys())."],"exampleFix":"// before\nCatalogTable newTable = new CatalogTableImpl(schema, Collections.singletonList(\"dt\"), props, \"\");\nflinkCatalog.alterTable(path, newTable, false);\n// after\nCatalogTable newTable = new CatalogTableImpl(schema, oldTable.getPartitionKeys(), props, \"\");\nflinkCatalog.alterTable(path, newTable, false);","handlingStrategy":"validation","validationCode":"if (!newTable.getPartitionKeys().equals(oldTable.getPartitionKeys())) {\n  throw new IllegalArgumentException(\"partition keys must remain unchanged\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never modify partition keys through alterTable","Plan partition-spec changes via new-table migration or Iceberg core API","Preserve getPartitionKeys() when constructing replacement CatalogTables"],"tags":["flink","partitioning","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-23T08:17:48.524Z"}