Skip to content

[Server] Implement the Iceberg renameTable endpoint - #1849

Merged
yili-db merged 3 commits into
unitycatalog:mainfrom
moomindani:feat/iceberg-rename-table
Sep 10, 2026
Merged

yili-db merged 3 commits into
unitycatalog:mainfrom
moomindani:feat/iceberg-rename-table

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Part of #1846.

The rename endpoint had no route, so an engine's ALTER TABLE ... RENAME TO was answered with a 404
for a path this server does not serve. Unity Catalog has renamed tables all along, through
TableRepository.renameTable, which already refuses a name that is taken; the operation was only
missing from the Iceberg REST surface.

This serves it and advertises V1_RENAME_TABLE with the other write endpoints.

  • The table is resolved the way loadTable resolves it, so a table this API does not expose cannot be
    renamed through it.
  • A destination name that is taken is the spec's 409, which is what the repository already raises.
  • A destination in a different namespace is refused as unimplemented (501). Unity Catalog has no way
    to move a table between schemas, and that status tells a client the catalog does not do it, rather
    than describing a well-formed request as malformed. The spec lists 406 for an unsupported rename;
    say so if you would rather have that.

For users: ALTER TABLE ... RENAME TO works from any Iceberg client, within a namespace.

testRenameTable pins the 204 and that the table is listed and loadable under its new name, the 404
for a table that is not there, the 409 for a name that is taken, and the 501 for a cross-namespace
rename. It fails on an unfixed tree and passes with the fix; the full server/test suite shows no
failure attributable to this change.

// Only tables this API serves can be renamed through it; anything else is not a table it has.
TableRepository.IcebergTableState state =
tableRepository.getIcebergTableState(catalog, namespace, request.source().name());
if (state.metadataLocation() == null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropTable has this:

    TableRepository.IcebergTableState state =
        tableRepository.getIcebergTableState(catalog, namespace, table);
    if (state.dataSourceFormat() != DataSourceFormat.ICEBERG) {
      throw new BadRequestException(
          "Table %s was not created through the Iceberg REST catalog; drop it through the Unity"
              + " Catalog API instead.",
          fullName);
    }

UniForm tables are supposedly readonly via IRC endpoints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. renameTable makes the same check dropTable makes and answers 400, with a message naming the rename rather than the drop: a UniForm table is a Delta table these endpoints read, so renaming it here would rename the Delta table under its own API.

That also changed where the test belongs, which lines up with your other comment: the rename now runs against the native table testIcebergTableWriteLifecycle creates, and the read-only case joins the commit and drop rejections testTable already makes against a UniForm table.

@AuthorizeResourceKey(METASTORE)
public HttpResponse renameTable(@Param("catalog") String catalog, RenameTableRequest request) {
serverProperties.checkIcebergTableEnabled();
Namespace source = request.source().namespace();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request is not validated.
A malformed request with null source/destination would throw NPE and 500, instead of 400.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed -- request.validate() before anything reads it, so a body missing either identifier is the 400 it should be instead of the 500 the NPE produced. RegisterTableRequest in #1851 was already validated this way; the rest of the write endpoints take no body or validate it, so this was the only one.

}

@Test
public void testRenameTable() throws Exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better fold this test into testIcebergTableWriteLifecycle and between some steps in that test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The rename runs in testIcebergTableWriteLifecycle between the commit and the drop -- against the native table that test creates, which is also what the read-only check above requires -- and renames back at the end so the drop still finds the table. The 404, 409, cross-namespace and malformed-request cases go with it. Without the endpoint they fail with 404 where 204 is expected.

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase

The rename endpoint was not implemented, so an engine's ALTER TABLE ... RENAME TO against this catalog
was answered by Armeria before any service was reached, with a 404 for a path it does not serve. The
repository has renamed tables all along -- TableRepository.renameTable, which already refuses a name
that is taken -- it was only missing from the Iceberg REST surface.

Serve it, and advertise V1_RENAME_TABLE with the other write endpoints. A table this API does not
expose is not renameable through it, so the table is resolved the way loadTable resolves it first; a
name that is taken is the spec's 409, which is what the repository already raises.

A rename whose destination is a different namespace is refused as unimplemented rather than
half-applied: Unity Catalog has no way to move a table between schemas, and the status says so to a
client instead of describing the request as malformed.

Signed-off-by: Noritaka Sekiyama <[email protected]>
…ts request

Review follow-up, two real fixes and a test move.

A UniForm table is a Delta table these endpoints read, so renaming one here
would rename the Delta table under its own API. renameTable now makes the same
check dropTable makes and answers 400, with a message naming the rename rather
than the drop.

RenameTableRequest was used without validating it, so a body missing either
identifier reached request.source() as null and came back as a 500. Calling
validate() first turns that into the 400 it should be.

The cases move out of a test of their own: the rename itself goes into
testIcebergTableWriteLifecycle between the commit and the drop, against the
native table that test creates and renaming back so the drop still finds it,
and the read-only case joins the commit and drop rejections testTable already
makes against a UniForm table. Without the endpoint they fail with 404 where
204 and 400 are expected.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@moomindani
moomindani force-pushed the feat/iceberg-rename-table branch from 90bb893 to b7d1655 Compare September 10, 2026 00:54
@moomindani

Copy link
Copy Markdown
Contributor Author

Rebased onto 4ee2b248.

- Resolve add/add conflict in `IcebergRestCatalogTest.java`:
    - keep the PR's `renameRequest` helpers
    - keep main's `testLoadTableSnapshotsParameter` and `loadedSnapshotIds`
- `renameTable` and main's `loadTable` `snapshots` change coexist; `server/Test/compile` is clean.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db merged commit 4e9562a into unitycatalog:main Sep 10, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants