danhuawang opened a new issue, #11538:
URL: https://github.com/apache/gravitino/issues/11538

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   When renaming an Iceberg table stored in a Gravitino Glue catalog (via the 
Spark connector or Java client), the operation fails with 
`IllegalArgumentException: Unsupported table change for Iceberg table: 
RenameTable`, even though the underlying Iceberg `GlueCatalog` natively 
supports `renameTable`.
   
   The server-side `GlueIcebergTableHelper.alterTable` only handles 
`ColumnChange`, `SetProperty`, and `RemoveProperty`; every other change 
(including `RenameTable`) hits the `else` branch and throws. So rename for 
Iceberg tables in Glue is never implemented.
   
   Note this is distinct from the non-Iceberg (Hive) path, which correctly 
throws `UnsupportedOperationException("Glue does not support table rename")` 
because Glue Hive tables genuinely cannot be renamed. Iceberg tables are 
wrongly treated the same way.
   
   This is not a Spark connector issue — the connector correctly forwards the 
rename request via REST. The gap is in the `catalog-glue` server module.
   
   ### Error message and/or stacktrace
   
   ```
   java.lang.IllegalArgumentException: Failed to operate table(s) 
[..._ice_rename_old] operation [ALTER] under schema [..._db], reason 
[Unsupported table change for Iceberg table: RenameTable]
   java.lang.IllegalArgumentException: Unsupported table change for Iceberg 
table: RenameTable
   at 
org.apache.gravitino.catalog.glue.GlueIcebergTableHelper.alterTable(GlueIcebergTableHelper.java:409)
   at 
org.apache.gravitino.catalog.glue.GlueCatalogOperations.alterIcebergTable(GlueCatalogOperations.java:597)
   at 
org.apache.gravitino.catalog.glue.GlueCatalogOperations.alterTable(GlueCatalogOperations.java:514)
   at 
org.apache.gravitino.catalog.glue.GlueCatalogOperations.alterTable(GlueCatalogOperations.java:100)
   at 
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$alterTable$8(TableOperationDispatcher.java:272)
   ...
   at 
org.apache.gravitino.client.RelationalCatalog.alterTable(RelationalCatalog.java:250)
   at 
org.apache.gravitino.spark.connector.catalog.BaseCatalog.renameTable(BaseCatalog.java:360)
   at 
org.apache.spark.sql.execution.datasources.v2.RenameTableExec.run(RenameTableExec.scala:51)
   ...
   ```
   
   ### How to reproduce
   
   1. Create a Gravitino Glue catalog with Iceberg support
   2. Create an Iceberg table: `CREATE TABLE catalog.db.t_old (id INT, val 
STRING) USING iceberg`
   3. Insert a row: `INSERT INTO catalog.db.t_old VALUES (1, 'before_rename')`
   4. Rename it: `ALTER TABLE catalog.db.t_old RENAME TO catalog.db.t_new`
   5. Step 4 fails with `IllegalArgumentException: Unsupported table change for 
Iceberg table: RenameTable`
   
   Reproduces on main with Spark 3.5 and Iceberg 1.11.0.
   
   ### Additional context
   
   The underlying Iceberg `org.apache.iceberg.aws.glue.GlueCatalog` implements 
`renameTable(from, to)`, so the capability exists; it is simply not wired up in 
Gravitino's `catalog-glue` module.
   
   Suggested fix: handle `TableChange.RenameTable` in 
`GlueIcebergTableHelper.alterTable` (or route it from 
`GlueCatalogOperations.alterIcebergTable`) by calling the Iceberg catalog's 
`renameTable`. The existing unit test 
`TestGlueCatalogOperationsForIceberg#testAlterTable_icebergRenameThrows`, which 
currently asserts the throwing behavior, should be updated accordingly since it 
codifies the bug.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to