Skip to content

[Server] Implement the Iceberg registerTable endpoint - #1851

Closed
moomindani wants to merge 1 commit into
unitycatalog:mainfrom
moomindani:feat/iceberg-register-table
Closed

moomindani wants to merge 1 commit into
unitycatalog:mainfrom
moomindani:feat/iceberg-register-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

Fixes #1850.

The register endpoint was not served, so a table whose Iceberg metadata already exists could not be
brought into this catalog through the REST API: the request was answered with a 404 for a path this
server does not have. That is the path an engine takes to adopt a table written elsewhere, and the one a
migration onto Unity Catalog goes through.

This serves it and advertises V1_REGISTER_TABLE with the other write endpoints, so it is gated the
same way the other Iceberg writes are.

  • The metadata file is read and never written. The table's columns, properties and location come from
    the document the request names, and because nothing is written there is nothing to clean up if the
    row cannot be created -- unlike createTable, which has to delete the metadata it wrote.
  • The file has to sit inside the table location it declares, so a metadata file cannot register a table
    rooted somewhere it does not live. MetadataService gained a read for a table Unity Catalog does not
    have yet, because the location it validates against cannot come from a persisted row that is not
    there.
  • A name that is already taken is the spec's 409. When the request asks to overwrite, the given file is
    committed over whatever the table points at now, through the same compare-and-swap a commit uses: a
    commit that lands in between is reported as a conflict rather than silently overwritten. Overwriting a
    table that is not a native Iceberg table is refused by that commit path, as it is for any other
    commit. Iceberg's client does send overwrite, which is why it is implemented rather than rejected.

For users: an existing Iceberg table can be adopted into Unity Catalog by naming its metadata file, and
the table is a full member of the catalog afterwards -- listed, loadable, and committable.

testRegisterTable pins the response's metadata pointer, that the table is then listed and loadable and
carries its columns in Unity Catalog, the 409 for a taken name, the 200 when overwrite is asked for, the
404 for a namespace that does not exist, and the rejection of a metadata file outside the location it
declares. It fails on an unfixed tree and passes with the fix; the full server/test suite shows no
failure attributable to this change (the one failure here is the GCP credential test, which needs
credentials this machine does not have).

The register endpoint was not implemented, so a table whose Iceberg metadata already exists could not
be brought into this catalog through the REST API: the request was answered by Armeria with a 404 for a
path it does not serve. That is the path an engine takes to adopt a table written elsewhere, and the
one a migration onto Unity Catalog goes through.

Serve it, and advertise V1_REGISTER_TABLE with the other write endpoints.

The metadata file is read and never written: the table's columns, properties and location come from the
document the request names, and because nothing was written there is nothing to clean up if the row
cannot be created. The file has to sit inside the table location it declares, so a metadata file cannot
register a table rooted somewhere it does not live -- MetadataService gained a read for a table Unity
Catalog does not have yet, since the location cannot come from a persisted row that is not there.

A name that is already taken is the spec's 409, unless the request asks to overwrite: then the given
file is committed over whatever the table points at now, through the same compare-and-swap a commit
uses, so a commit that lands in between is reported as a conflict rather than silently overwritten.
Overwriting a table that is not a native Iceberg table is refused by that commit path, as it is for
any other commit.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@yili-db

yili-db commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks for putting this together. Before we get into the code, I want to step back on whether /register fits our model at all — I'm not sure it does, at least not the fresh-register case.

Our UC Iceberg table model is: a table has one location, and governed by UC, and everything (data + metadata) lives under it. For managed tables it is assigned by UC, and for external tables it is chosen by client. Either way the location is governed by UC once the table is created.
RegisterTableRequest is {name, metadata-location, overwrite} — there's no table location in the request. So on a fresh register UC never gets to choose or approve or even know where the table lives and where is the storage boundary; it can only do location = read(metadataFile).location and trust it. And that is risk as there isn't any guarantee by spec that the location is indeed the storage boundary.

So I don't think we are ready to implement this endpoint in UC yet.

@moomindani

Copy link
Copy Markdown
Contributor Author

Fair enough -- feel free to close it. The intent across these PRs was spec coverage, filling in the Iceberg REST endpoints UC does not serve yet, and register turns out not to fit UC's model the way the others do; that is not something to settle quickly, so I would rather park it than force it.

One note for whenever it comes up again: besides the request carrying no location for UC to approve, the overwrite path is unsound on its own terms -- it commits the given metadata file over an existing table's pointer without checking the file is under the location UC governs for that table (commitIcebergTable never compares against the table's url; the normal commit path is safe only because the service derives the location from the table itself).

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.

Iceberg REST catalog does not serve registerTable

2 participants