Skip to content

Implement native Iceberg REST catalog write endpoints - #1696

Merged
yili-db merged 8 commits into
unitycatalog:mainfrom
iamkiayun:feat/iceberg-rest-write-endpoints
Aug 24, 2026
Merged

yili-db merged 8 commits into
unitycatalog:mainfrom
iamkiayun:feat/iceberg-rest-write-endpoints

Conversation

@iamkiayun

Copy link
Copy Markdown
Contributor

Summary

Unity Catalog's Iceberg REST catalog can now create and commit native Iceberg tables instead of limiting Iceberg clients to read-only Delta UniForm metadata. Spec-aware clients can discover the write endpoints, create managed or external tables, perform staged creates, commit new snapshots with conflict protection, and drop catalog-created tables.

This draft is a current-main, DCO-clean continuation of the implementation developed by @dataders in #1618. The implementation credit and history are called out here explicitly; the commits were replayed onto current upstream because the original branch is behind main and its DCO check cannot be repaired by a third-party sign-off.

Design decisions

  • Native ICEBERG tables are writable, while Delta UniForm tables remain read-only so Iceberg metadata cannot diverge from the Delta log.
  • Commits write a new metadata file and then compare-and-swap the catalog's metadata pointer under a row lock. Concurrent losers receive a conflict instead of silently overwriting another snapshot.
  • Location-less creates receive a managed location under Unity Catalog's configured managed root. Explicit locations remain external.
  • Staged creates remain unregistered until the client's assert-create commit materializes the table.
  • Storage credentials are vended according to the requested read or write privileges, and the write routes retain metastore-owner authorization.

The remaining endpoint families in the broader Iceberg REST specification—such as multi-table transactions, rename/register, namespace property updates, and view writes—remain outside this change.

Validation

  • Focused Iceberg, schema conversion, metadata, credential, and cloud-vendor suites: 24 passed, 0 failed.
  • Full server suite: 313 total, 311 passed, 2 skipped, 0 failed, 0 errors.
  • The two skipped classes are the MySQL and PostgreSQL Delta Commits Testcontainers suites. The local OrbStack endpoint requires Docker API 1.40+, while this repository's older Testcontainers client advertises API 1.32. Upstream CI should exercise these suites in its supported Docker environment.
  • serverShaded/assembly: passed.
  • Checkstyle and git diff --check: passed.
  • The DCO rewrite changed commit metadata only; the source tree hash remained identical before and after the rewrite.

Known interoperability checks

  • Recheck the table HEAD endpoint with a real HTTP/1.1 Iceberg client; the Java integration suite passes, but an earlier local client probe could stall.
  • Lowercase REST boolean values work for purgeRequested; mixed-case values such as False remain an optional compatibility improvement.

Related

Related: #3

Continuation of and implementation credit: #1618 by @dataders.

Post-deploy monitoring & validation

  • Window/owner: PR author and maintainers during CI, release qualification, and the first 24 hours of any deployment enabling the new endpoints.
  • Exercise: create a namespace and native Iceberg table, append two snapshots, force one concurrent stale commit, reload the table, and drop it through a released Iceberg client.
  • Healthy signals: create/commit/load/drop return expected 2xx responses; stale commits return 409; the stored metadata location advances once per successful commit; data remains readable after server restart.
  • Watch logs for: CommitFailedException, UPDATE_REQUIREMENT_CONFLICT, Failed to update Iceberg metadata location, credential-vending failures, and metadata read/write exceptions.
  • Failure/rollback trigger: unexpected 5xx responses, catalog pointers referencing missing metadata, unauthorized write credentials, or lost concurrent updates. Stop advertising the write endpoints and revert this change while preserving the catalog database and Iceberg metadata for diagnosis.

PR checklist

  • Description explains the behavior and design boundaries.
  • Unit and integration coverage is included.
  • Focused and full local server validation completed.
  • Upstream CI validates the Docker-backed database suites.
  • Maintainers confirm whether separate user documentation is required.

Compound Engineering

@iamkiayun
iamkiayun marked this pull request as ready for review July 21, 2026 05:26
@yili-db

yili-db commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this PR. Will take a look.

@yili-db

yili-db commented Jul 25, 2026 •

Copy link
Copy Markdown
Collaborator

I am still reviewing as it's a large PR implementing a major new feature.

@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.

Thanks for taking this on. This is a feature a lot of people have been asking for and we'd really like to get it in, so thanks for pushing it forward.

It's a big change and a lot of solid work went into it, so please don't be discouraged by the number of comments below. That's just what comes with something this size, not a sign anything's wrong.

I left 18 inline comments, a mix of small stuff and a few worth discussing. Happy to talk through any of them. If you can work through these and refresh the PR, I'll keep reviewing in passes until we get it merged.

@@ -32,10 +32,6 @@ public class FileIOFactory {

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.

Just FYI I have a PR to consolidate this file into FileOperations so there will be conflict.
#1687

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.

Just FYI I have a PR to consolidate this file into FileOperations so there will be conflict.

Thank you for the heads-up. I kept the overlapping FileIOFactory surface narrow and did not duplicate the open #1687 consolidation. I’ll reconcile any remaining conflict after that PR lands.

new CreateSchema().name(schemaName).catalogName(catalog).properties(request.properties());
String resp;
try {
resp = schemaService.createSchema(createSchema).aggregate().join().contentUtf8();

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.

This (service calling another service) is the pre-existing anti-pattern and it even complicates things.
Here it can simply be done with:

    SchemaInfo schemaInfo = schemaRepository.createSchema(createSchema);
    CatalogInfo catalogInfo = catalogRepository.getCatalog(catalog);
    initializeHierarchicalAuthorization(schemaInfo.getSchemaId(), catalogInfo.getId());

3 lines of dup code but it breaks the anti-pattern and saves the .aggregate().join().contentUtf8() plus JsonUtils.getInstance().readValue(resp, SchemaInfo.class).

@iamkiayun iamkiayun Jul 30, 2026 •

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.

This (service calling another service) is the pre-existing anti-pattern and it even complicates things.

Updated in 0cbbdf9. Namespace operations now call the repositories directly and initialize hierarchical authorization inside the Iceberg service, removing the response aggregation and JSON round-trip.

String resp;
try {
resp = schemaService.createSchema(createSchema).aggregate().join().contentUtf8();
} catch (BaseException e) {

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.

Catching this exception should be unnecessary. IcebergRestExceptionHandler should handle it already.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Catching this exception should be unnecessary. IcebergRestExceptionHandler should handle it already.

Updated in 0cbbdf9. The endpoint-local duplicate translation is removed, and repository error codes are now mapped centrally by IcebergRestExceptionHandler.

}
}

/** Looks up the UC table entry, translating UC's not-found error into the Iceberg shape. */

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.

Doesn't IcebergRestExceptionHandler already do this? If not, it should be fix instead.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Doesn't IcebergRestExceptionHandler already do this? If not, it should be fix instead.

Updated in 0cbbdf9. The local not-found wrapper is removed; the centralized handler now produces the Iceberg-shaped table/schema not-found and conflict responses.

@@ -36,18 +32,24 @@ public TableConfigService(
}

public Map<String, String> getTableConfig(TableMetadata tableMetadata) {

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.

You can just change this function to make it explicit that privileges is always provided.
There are only two callers to it. Just change them to say READ_ONLY.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Make it explicit that privileges is always provided.

Updated in 0cbbdf9. The implicit overload was removed, so every getTableConfig caller now supplies its credential privileges explicitly.

// spec compatibility but does not delete files); MANAGED tables have their storage directory
// removed by the repository's delete path.
tableService.deleteTable(fullName);
// 200 instead of the spec's 204: Armeria stalls body-less 204 responses on HTTP/1.1

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.

Armeria stalls body-less 204 responses on HTTP/1.1

Is there a source for that? I search on internet and couldn't find it.
It seems that the apache/iceberg-rest-fixture returns 200 because it simply forgot to return 204.
Clients do accept 200 as well so 200 is also fine. But this "Armeria stalls" claim seems inaccurate.

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.

Or is it actually caused by the bug being fixed by #1716?

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.

Or is it actually caused by the bug being fixed by #1716?

Yes. After rebasing the merged #1716 change, I confirmed the issue was the no-body transcoder path; my earlier broad Armeria claim was inaccurate. The drop endpoints now return bodyless 204 responses, covered by the server tests.

yield String.format("decimal(%d,%d)", decimal.precision(), decimal.scale());
}
case VARIANT -> "variant";
default ->

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.

Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.

Updated in 0cbbdf9. This conversion direction now explicitly documents that Iceberg has no standard GEOMETRY/GEOGRAPHY primitive and keeps unsupported extensions rejected.

case STRUCT -> ColumnTypeName.STRUCT;
case LIST -> ColumnTypeName.ARRAY;
case MAP -> ColumnTypeName.MAP;
default ->

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.

Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.

Updated in 0cbbdf9. The UC type-name conversion path now has the same explicit unsupported handling for GEOMETRY/GEOGRAPHY.

FileIO fileIO =
fileIOFactory.getFileIO(NormalizedURL.from(metadataLocation), CredentialContext.READ_WRITE);

CompletableFuture.runAsync(

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.

I've seen this pre-existing pattern of runAsync then join in this repo. But it is pointless.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

The pre-existing pattern of runAsync then join ... is pointless.

Updated in 0cbbdf9. The async wrappers were removed; metadata reads, writes, and cleanup now use the synchronous Iceberg/FileIO operations directly.

}

/** Builds the location of the next metadata file, following the common Iceberg naming scheme. */
public static String newMetadataLocation(TableMetadata tableMetadata, int version) {

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.

Return a NormalizedURL to explicitly normalize the location.

@iamkiayun iamkiayun Jul 30, 2026 •

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.

Return a NormalizedURL to explicitly normalize the location.

Updated in 0cbbdf9. newMetadataLocation now returns NormalizedURL, and the metadata helper boundaries use it consistently.

@iamkiayun
iamkiayun force-pushed the feat/iceberg-rest-write-endpoints branch from 5d21432 to 55b7fb8 Compare July 30, 2026 07:16
@iamkiayun

iamkiayun commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@yili-db Thank you for the detailed review and for taking the time to work through this large feature with me. Your comments helped align the implementation more closely with the existing Unity Catalog architecture and strengthened the transaction and consistency guarantees.

I rebased the branch on the current main and pushed the review updates in 0cbbdf9. The main changes are:

  • replaced service-to-service calls with direct repository operations and local authorization hierarchy updates;
  • centralized Iceberg REST exception translation;
  • moved managed Iceberg creates onto the shared staging-table lifecycle;
  • made initial table registration and metadata-pointer persistence atomic;
  • made commits atomically synchronize the Iceberg pointer, UC columns, UC properties, and audit fields under a row lock;
  • added permission-aware read/write credential fallback while keeping UniForm read-only;
  • adopted NormalizedURL and shared file-operation helpers, removed async-then-block metadata wrappers, and restored bodyless 204 responses after rebasing [Server] Fix URL transcoder hanging on responses with no body #1716;
  • expanded lifecycle, staging, concurrent-commit, metadata, schema/property synchronization, and credential tests.

Validation completed with 349 server tests: 347 passed, 0 failed, and 2 Docker-dependent suites were skipped because Docker is unavailable in my local environment. Formatting, checkstyle, shaded assembly, and git diff --check also pass.

I replied to each inline thread with the corresponding change and left the threads open for your confirmation. I appreciate your effort in helping review this contribution, and I’ll continue working through any further concerns or comments you raise in the next pass.

@iamkiayun
iamkiayun force-pushed the feat/iceberg-rest-write-endpoints branch from 55b7fb8 to 0cbbdf9 Compare July 30, 2026 07:21
@yili-db
yili-db self-requested a review July 31, 2026 08:53
@yili-db

yili-db commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Thank you @iamkiayun . Will take another look.

public TableInfo createTableForIceberg(CreateTable createTable, NormalizedURL metadataLocation) {
if (createTable.getDataSourceFormat() != DataSourceFormat.ICEBERG) {
throw new BaseException(
ErrorCode.INVALID_ARGUMENT, "createTableForIceberg requires ICEBERG format.");

@yili-db yili-db Aug 5, 2026 •

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.

nit: this indicates an implementation bug not invalid input. The only caller is expected to set it and it does.
Use ErrorCode.INTERNAL instead.


public TableInfo createTable(CreateTable createTable) {
return createTableImpl(createTable, Optional.empty(), (session, dao, tableInfo) -> tableInfo);
return createTableImpl(

@yili-db yili-db Aug 5, 2026 •

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.

Note that you have if (createTable.getDataSourceFormat() != DataSourceFormat.ICEBERG) for Iceberg call path. The other two callers of createTableImpl should check that getDataSourceFormat is not ICEBERG.

@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.

Can you please add a server property server.iceberg-table.enabled and default to false? Then guard the create/write endpoints with it. This way we treat it as an experimental feature and promote it to production ready later.
For example:

MANAGED_TABLE_ENABLED("server.managed-table.enabled", "true", BOOLEAN_VALIDATOR),


@Override
protected BaseException toBaseException(Throwable cause) {
if (cause instanceof BaseException baseException) {

@yili-db yili-db Aug 5, 2026 •

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.

This function toBaseException is meant to convert other exceptions to BaseException.
The whole conversion is simply createErrorResponse(toBaseException(cause)). toBaseException makes sure all exceptions are converted to BaseException if they aren't already one. Then createErrorResponse can uniformly write out error response according to the BaseException.

To correctly handle exceptions for Iceberg:

  1. For BaseException thrown by UC server code, we need to eventually map them into Iceberg ErrorResponse:
    a. Make a new enum IcebergErrorType { NO_SUCH_TABLE(404, "NoSuchTableException"), ...}
    b. Each ErrorCode has a DeltaErrorType deltaErrorType defined. A new field IcebergErrorType icebergErrorType can be added.
    c. Finally IcebergRestExceptionHandler.createErrorResponse can use BaseException and the ErrorCode inside to generate the correct response (existing impl is not correct).

  2. For Iceberg exceptions thrown by Iceberg code:
    a. Convert them into corresponding BaseException with correct ErrorCode (and correct IcebergErrorType inside).
    b. IcebergRestExceptionHandler.createErrorResponse writes out correct response the same way it does to server code thrown exceptions.
    c. The current implementation of IcebergRestExceptionHandler.getOriginalException is lame as it simply finds a non-BaseException even if it's not a Iceberg exception at all.

This can be done in a separate/concurrent PR.

return query.uniqueResult(); // Returns null if no result is found
}

public boolean isUncommittedStagingLocation(NormalizedURL stagingLocation) {

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.

This is TOCTOU-shaped read. The access to DB is not required since all this function does is to figure out "MANAGED or EXTERNAL". A simple if (url.toString().contains(Constants.MANAGED_STORAGE_PREFIX)) could do the trick. The actual validation and ownership check is done by:

            // Find and commit staging table with the same staging location
            StagingTableDAO stagingTableDAO =
                repositories
                    .getStagingTableRepository()
                    .commitStagingTable(session, callerId, storageLocation);

if (createTable.getDataSourceFormat() != DataSourceFormat.DELTA) {
if (createTable.getDataSourceFormat() != DataSourceFormat.DELTA
&& createTable.getDataSourceFormat() != DataSourceFormat.ICEBERG) {
throw new BaseException(

@yili-db yili-db Aug 5, 2026 •

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.

why remove this comment?

* concurrent Iceberg REST commits serialize. Lock-wait timeouts and deadlock victims surface as
* {@code UPDATE_REQUIREMENT_CONFLICT} (409) instead of a generic 500.
*/
private static void lockTableForUpdate(

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.

An identical function lockTableForCommit exists in DeltaCommitRepository.
Please move it to RepositoryUtils so that you can reuse it.

openinx
openinx previously requested changes Aug 5, 2026

@openinx openinx 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.

Left comments on the remaining blockers.

Also: please rebase onto current main. #1726 added the isCloudStorageRoot guard on EXTERNAL creates; this branch is missing it relative to main (merge-base predates that change, so it does not show as a deletion in the PR diff). Restoring / picking that up should be part of the rebase.

private final SchemaService schemaService;
private final TableConfigService tableConfigService;
private final MetadataService metadataService;
private final CatalogRepository catalogRepository;

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 add a server property server.iceberg-table.enabled (default false) and gate the create/write/delete endpoints behind it. Also stop advertising V1_CREATE_NAMESPACE / V1_CREATE_TABLE / V1_UPDATE_TABLE / V1_DELETE_TABLE here when the flag is off, so clients do not discover write routes that will fail. Treat this as experimental until we promote it.

createTable, Optional.empty(), Optional.empty(), (session, dao, tableInfo) -> tableInfo);
}

public TableInfo createTableForIceberg(CreateTable createTable, NormalizedURL metadataLocation) {

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.

createTableForIceberg already asserts DataSourceFormat.ICEBERG. The other two createTableImpl callers (createTable / createTableForDelta) should reject ICEBERG — OpenAPI now exposes the enum value, so UC/Delta create can otherwise register a native Iceberg row without a metadata pointer.

return query.uniqueResult(); // Returns null if no result is found
}

public boolean isUncommittedStagingLocation(NormalizedURL stagingLocation) {

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.

This is TOCTOU-shaped: a DB read only to decide MANAGED vs EXTERNAL. Prefer url.toString().contains(Constants.MANAGED_STORAGE_PREFIX) instead. Ownership / already-committed validation already happens in commitStagingTable when the create path runs.

* concurrent Iceberg REST commits serialize. Lock-wait timeouts and deadlock victims surface as
* {@code UPDATE_REQUIREMENT_CONFLICT} (409) instead of a generic 500.
*/
private static void lockTableForUpdate(

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.

An identical helper already exists as DeltaCommitRepository.lockTableForCommit. Please move it to RepositoryUtils and reuse it from both call sites instead of duplicating.

dao.setColumnCount(newColumns.size());

MutablePropertyMap properties = MutablePropertyMap.load(session, dao.getId());
properties.removeAll(new ArrayList<>(properties.asMap().keySet()));

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.

This replaces the whole UC property set from the Iceberg metadata instead of applying the commit's SetProperties / RemoveProperties incrementally like DeltaUpdateTableMapper does. That's fine as it keeps the UC row a faithful projection and won't drift if Iceberg adds new update types.

Worth a comment though, because it means UC should never persist a server-owned property on a native Iceberg table: the next commit erases anything not in the client's metadata. The Delta path is the opposite as that's the intentional design, so it's an easy thing to generalize wrongly later.

Non-blocking.

properties.putAll(tableProperties);
properties.flush(session, dao.getId());

dao.setUniformIcebergMetadataLocation(newMetadataLocation.toString());

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.

uniform_iceberg_metadata_location now holds two different things:

  • the UniForm-derived pointer (Delta is authoritative)
  • and the native Iceberg pointer (Iceberg is authoritative), told apart only by data_source_format.

Safe today, since the they belong to two different types of tables. But a comment on the DAO field would help, so nobody later reads non-null as "this is a UniForm table" and adds an unguarded reader.

Non-blocking, and not suggesting a rename.

if (createTable.getDataSourceFormat() != DataSourceFormat.DELTA) {
if (createTable.getDataSourceFormat() != DataSourceFormat.DELTA
&& createTable.getDataSourceFormat() != DataSourceFormat.ICEBERG) {
throw new BaseException(

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.

why remove this comment?

node.put("name", field.name());
node.set("type", typeJson(field.type()));
node.put("nullable", field.isOptional());
node.set("metadata", MAPPER.createObjectNode());

@yili-db yili-db Aug 6, 2026 •

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.

Maybe save the comment like this?

  ObjectNode metadata = MAPPER.createObjectNode();
  if (field.doc() != null) {
    metadata.put("comment", field.doc());
  }
  node.set("metadata", metadata);

tableMetadata
.properties()
.getOrDefault(
TableProperties.WRITE_METADATA_LOCATION, tableMetadata.location() + "/metadata");

@yili-db yili-db Aug 6, 2026 •

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.

I see that here both the value from WRITE_METADATA_LOCATION or tableMetadata.location() could be set by client request and be set to any random path.
The metadata location should be validated against the table location which is peristed in table dao. For example UniForm tables have this:


This is true for all Iceberg endpoints where clients can specify a metadata location in request.

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.

Also a related PR #1749

@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.

Left comments. Please take a look.

For a major feature implementation like this, multiple rounds of review with many comments are very much expected. You contribution is very welcomed! Thank you!

* Returns the location form Iceberg's local FileIO reports after a read. Cloud locations remain
* normalized URIs; local file URIs become paths.
*/
public static String toIcebergMetadataLocation(NormalizedURL metadataLocation) {

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 add a unit test.


// Locations arrive both as plain paths and as file: URIs (matching what
// org.apache.iceberg.Files.localInput accepts).
private static File toLocalFile(String path) {

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 unit test it.

if (ucTableExists(catalog, namespace, request.name())) {
throw new AlreadyExistsException("Table already exists: %s.%s", namespace, request.name());
}
metadataService.prepareTableLocation(tableMetadata);

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.

This is pre-existing pattern:

void function(TableMetadata tableMetadata) {
  doSomething(tableMetadata.location());

This is not good:

  1. From call site it's hard to understand that this function only needs the location, not anything else from TableMetadata
  2. For the same reason as https://github.com/unitycatalog/unitycatalog/pull/1696/changes#r3727123916, it's best to have this function explicitly take a table location instead so that all these path and cred operations are explicitly limited to persisted table dao location.

So here it would be .addAllConfig(tableConfigService.getTableConfig(location, READ_WRITE)) and much easier to reason about.

While you are here, please fix existing function as well. Thanks!

NormalizedURL metadataLocation = MetadataService.newMetadataLocation(tableMetadata, 0);
TableMetadata committed =
TableMetadata.buildFrom(tableMetadata)
.discardChanges()

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 comment why .discardChanges() is called here

request.updates().forEach(update -> update.applyTo(builder));
TableMetadata updatedWithoutLocation = builder.build();
if (updatedWithoutLocation.changes().isEmpty()) {
return LoadTableResponse.builder()

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 comment "No-op update"


NormalizedURL newMetadataLocation =
MetadataService.newMetadataLocation(
updatedWithoutLocation, MetadataService.parseMetadataVersion(metadataLocation) + 1);

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.

This is another case of https://github.com/unitycatalog/unitycatalog/pull/1696/changes#r3727123916 that the user input location could come from persisted Iceberg commit file as well.
The same principal applies here too: the only location server should trust client having access to in all the Iceberg endpoints is the location persisted in table dao.

"Invalid requirement for a create commit: %s", requirement.getClass().getSimpleName());
}
}
if (ucTableExists(catalog, namespace, table)) {

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.

// The permanent table is not registered and no metadata file is written. Managed creates
// retain their staging row so duplicate validation, temporary credentials, and later
// lifecycle management use the same path as other managed tables.
if (ucTableExists(catalog, namespace, request.name())) {

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.

For managed table, this is already checked by stagingTableRepository.createStagingTable

Adds the core write surface to the Iceberg REST catalog service so Iceberg
clients (PyIceberg, Spark RESTCatalog, DuckDB iceberg extension) can create
and commit to tables, addressing the write-endpoint portion of unitycatalog#3:

- POST /v1/{prefix}/namespaces (createNamespace, delegating to SchemaService)
- POST /v1/{prefix}/namespaces/{ns}/tables (createTable: builds the initial
  TableMetadata, writes the 00000- metadata.json server-side, and registers
  the table in UC as an EXTERNAL table with the new ICEBERG data source
  format; staged creates are rejected with a clear error for now)
- POST /v1/{prefix}/namespaces/{ns}/tables/{table} (updateTable/commit:
  validates UpdateRequirements against the current metadata, applies
  MetadataUpdates, writes the next metadata.json, and linearizes the commit
  with a compare-and-swap on the stored metadata location under a pessimistic
  row lock; losers get a 409 CommitFailedException)
- DELETE /v1/{prefix}/namespaces/{ns}/tables/{table} (dropTable)

The new endpoints are advertised in GET /v1/config so spec-aware clients
discover write support. UniForm-enabled Delta tables remain readable but
explicitly read-only through this API, since their Iceberg metadata is
derived from the Delta log.

Storage credential vending is now privilege-aware: FileIOFactory and
TableConfigService take the requested privileges per call instead of the
previous hardcoded read-only set, and loadTable/createTable/commit responses
vend write-capable credentials for native Iceberg tables (all Iceberg REST
routes currently authorize as metastore owner). SimpleLocalFileIO gains
write/delete support for file:// locations, used by tests.

Iceberg schemas are converted to UC columns (Spark StructField type_json
shape) so REST-created tables are browsable through the UC API and UI.

Signed-off-by: Kia Yun <[email protected]>
@yili-db

yili-db commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Hi @iamkiayun, are you still going to finish this PR? I think it's very close to be getting merged. Just rebase and a few minor fixes.
Thanks!

	both modified:   server/src/main/java/io/unitycatalog/server/persist/DeltaCommitRepository.java
	both modified:   server/src/main/java/io/unitycatalog/server/service/IcebergRestCatalogService.java
	both modified:   server/src/main/java/io/unitycatalog/server/service/iceberg/TableConfigService.java
	both modified:   server/src/test/java/io/unitycatalog/server/service/IcebergRestCatalogTest.java

Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db enabled auto-merge (squash) August 24, 2026 10:20
@yili-db
yili-db disabled auto-merge August 24, 2026 10:20
@yili-db
yili-db enabled auto-merge (squash) August 24, 2026 10:21
@yili-db
yili-db disabled auto-merge August 24, 2026 10:24
@yili-db
yili-db enabled auto-merge (squash) August 24, 2026 10:25
@iamkiayun

Copy link
Copy Markdown
Contributor Author

Hi @yili-db — apologies for the delayed reply; I was tied up over the weekend. Yes, I’m still committed to finishing this PR. I saw that you applied the remaining minor fixes, merged the latest main into the branch, and approved the current head. I’m monitoring the remaining Spark 4.0 check and will address any issue it surfaces. I’ll also stay responsive to any further comments.

@tdas tdas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two comments... not blockers. Can be addressed in follow up PRs.


private TableInfoDAO findTableOrThrow(
Session session, String catalogName, String schemaName, String tableName) {
UUID schemaId =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[AI-assisted]

native iceberg metadata location lands in uniformIcebergMetadataLocation — the column now covers two concepts (delta-derived uniform vs native iceberg). can we at least doc the dual use on the DAO field?

'uniform' is a delta-UniForm concept; a future maintainer reads the name, assumes delta-only, and either mishandles native iceberg rows or adds a redundant column — the name lies about what it holds.

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.

Both comments being followed up at #1802
Thank you!

* Prepares the directories only after validating the table's client-supplied locations.
*/
public void prepareTableLocation(
TableMetadata tableMetadata, NormalizedURL persistedTableLocation) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[AI-assisted]

we should never eat an error without logging, even best-effort cleanup. log at warn before swallowing.

@yili-db
yili-db disabled auto-merge August 24, 2026 18:05
@yili-db
yili-db dismissed openinx’s stale review August 24, 2026 18:08

TD approved.

@yili-db
yili-db merged commit 8e26a03 into unitycatalog:main Aug 24, 2026
16 checks passed
@yili-db

yili-db commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

@iamkiayun @dataders
Thank you very much for your contribution! This is a major feature implementation and it took major effort to get it done. Your work is very much appreciated and we also look forward for more contribution from you if you are interested.

@dataders

Copy link
Copy Markdown
Contributor

@yili-db WOO HOOOOOO! LFG! Thanks for taking this over the line!

@iamkiayun

Copy link
Copy Markdown
Contributor Author

Thank you for the review, fixes, and merge, @yili-db! I really appreciate your guidance and help getting this contribution across the finish line.

moomindani added a commit to moomindani/unitycatalog that referenced this pull request Sep 5, 2026
IcebergRestExceptionHandler names the error type after the original exception's Java class, which is
right for an exception Iceberg raised. Unity Catalog's own BaseException is not one, and when it is
thrown directly it has no cause for getOriginalException to walk to, so it goes out as
"type": "BaseException".

unitycatalog#1696 addressed four of those codes by wrapping them in the Iceberg exception that stands for them,
which also moves the two already-exists codes off their legacy 400. The codes its switch does not
name still reach the client as "BaseException": verified on this commit's parent, a catalog that does
not exist answers 404 "type": "BaseException", and a namespace name Unity Catalog rejects -- the
dotted name a nested namespace arrives as -- answers 400 "type": "BaseException".

Iceberg's client switches on that field. ErrorHandlers.TableErrorHandler raises
NoSuchNamespaceException on a 404 only when the type names it, and NoSuchTableException otherwise, so
a missing catalog came back to the client as a missing table.

Name every error that is still a BaseException from its error code, mapping each code to the Iceberg
exception the client raises for that code's HTTP status. The switch over ErrorCode is exhaustive, so
a code added later has to name its Iceberg counterpart rather than silently inherit "BaseException".
Exceptions that did not come from Unity Catalog, including the ones unitycatalog#1696 wraps, keep naming
themselves, so the errors Iceberg raises are unaffected. Statuses and messages are unchanged.

Signed-off-by: Noritaka Sekiyama <[email protected]>
moomindani added a commit to moomindani/unitycatalog that referenced this pull request Sep 5, 2026
IcebergRestExceptionHandler names the error type after the original exception's Java class, which is
right for an exception Iceberg raised. Unity Catalog's own BaseException is not one, and when it is
thrown directly it has no cause for getOriginalException to walk to, so it goes out as
"type": "BaseException".

unitycatalog#1696 addressed four of those codes by wrapping them in the Iceberg exception that stands for them,
which also moves the two already-exists codes off their legacy 400. The codes its switch does not
name still reach the client as "BaseException": verified on this commit's parent, a catalog that does
not exist answers 404 "type": "BaseException", and a namespace name Unity Catalog rejects -- the
dotted name a nested namespace arrives as -- answers 400 "type": "BaseException".

Iceberg's client switches on that field. ErrorHandlers.TableErrorHandler raises
NoSuchNamespaceException on a 404 only when the type names it, and NoSuchTableException otherwise, so
a missing catalog came back to the client as a missing table.

Name every error that is still a BaseException from its error code, mapping each code to the Iceberg
exception the client raises for that code's HTTP status. The switch over ErrorCode is exhaustive, so
a code added later has to name its Iceberg counterpart rather than silently inherit "BaseException".
Exceptions that did not come from Unity Catalog, including the ones unitycatalog#1696 wraps, keep naming
themselves, so the errors Iceberg raises are unaffected. Statuses and messages are unchanged.

A request Iceberg's own parsers reject is named too. They raise IllegalArgumentException, which the
base handler already answers 400 for and whose message is already in Iceberg's terms, but whose class
name means nothing to a client; it is reported as BadRequestException, with the original failure kept
underneath it.

Signed-off-by: Noritaka Sekiyama <[email protected]>
moomindani added a commit to moomindani/unitycatalog that referenced this pull request Sep 10, 2026
IcebergRestExceptionHandler names the error type after the original exception's Java class, which is
right for an exception Iceberg raised. Unity Catalog's own BaseException is not one, and when it is
thrown directly it has no cause for getOriginalException to walk to, so it goes out as
"type": "BaseException".

which also moves the two already-exists codes off their legacy 400. The codes its switch does not
name still reach the client as "BaseException": verified on this commit's parent, a catalog that does
not exist answers 404 "type": "BaseException", and a namespace name Unity Catalog rejects -- the
dotted name a nested namespace arrives as -- answers 400 "type": "BaseException".

Iceberg's client switches on that field. ErrorHandlers.TableErrorHandler raises
NoSuchNamespaceException on a 404 only when the type names it, and NoSuchTableException otherwise, so
a missing catalog came back to the client as a missing table.

Name every error that is still a BaseException from its error code, mapping each code to the Iceberg
exception the client raises for that code's HTTP status. The switch over ErrorCode is exhaustive, so
a code added later has to name its Iceberg counterpart rather than silently inherit "BaseException".
Exceptions that did not come from Unity Catalog, including the ones unitycatalog#1696 wraps, keep naming
themselves, so the errors Iceberg raises are unaffected. Statuses and messages are unchanged.

A request Iceberg's own parsers reject is named too. They raise IllegalArgumentException, which the
base handler already answers 400 for and whose message is already in Iceberg's terms, but whose class
name means nothing to a client; it is reported as BadRequestException, with the original failure kept
underneath it.

Signed-off-by: Noritaka Sekiyama <[email protected]>
yili-db pushed a commit that referenced this pull request Sep 21, 2026
…geRequested (#1890)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated (nothing in `docs/` describes this parameter)

**Description of changes**

`pyiceberg` cannot drop an Iceberg table through Unity Catalog today.
Both of its entry points fail with a 400:

```
>>> catalog.drop_table(("my_schema", "t"))    # sends purgeRequested=False
pyiceberg.exceptions.BadRequestError: BadRequestException: Can't convert 'False' to type 'Boolean'.
>>> catalog.purge_table(("my_schema", "t"))   # sends purgeRequested=True
pyiceberg.exceptions.BadRequestError: BadRequestException: Can't convert 'True' to type 'Boolean'.
```

pyiceberg hands a Python `bool` straight to `requests`
(`params={"purgeRequested": purge_requested}` in
`pyiceberg/catalog/rest/__init__.py`), and `requests` renders it `True`
/ `False`. Armeria converts a `Boolean` parameter through a fixed table
of `true|TRUE|1` and `false|FALSE|0` (`StringUtil.stringToBoolean`), so
neither spelling converts, and `AnnotatedValueResolver` is in an
`internal` package, so the conversion is not pluggable. The Iceberg REST
spec types this parameter `boolean` with `default: false`, so a
capitalized spelling is a valid request and dropping the table is the
correct answer.

This is the second of the two interop checks #1696 named as open when
the native Iceberg write endpoints landed; the first (HEAD stalling) was
fixed in #1801.

**Technical changes**

- `IcebergRestCatalogService.dropTable` binds `purgeRequested` as a
`String` and validates it, reading `true` and `false` without regard to
case.
- The spellings Armeria already accepted, `1` and `0` included, keep
working, so the accepted set only grows. A value that is not a boolean
at all is still a 400, now with a message that names the offending value
(`Invalid purgeRequested: yes. It must be true or false.`) instead of
Armeria's `Can't convert 'yes' to type 'Boolean'.`
- The value itself stays unused: purging is not implemented, and
`dropTable` removes the table either way, as before.

**Two choices worth a reviewer's opinion**

- The helper validates rather than parses. Returning an
`Optional<Boolean>` no caller reads would be new surface with nothing
behind it, so the value is dropped after the check; when purge is
implemented this becomes a parse.
- Only the Iceberg endpoint is fixed here. Ten `Optional<Boolean>` query
parameters on the native surface (`force` on the catalog, schema,
function, model, credential and external-location deletes, plus
`include_browse`, `omit_properties`, `omit_columns`) reject `True` the
same way -- measured on a local server. That is the native API's own
contract rather than an Iceberg interop bug, and this repo's generated
Python client is unaffected because it lowercases booleans, so I left it
out and will file it separately.

**Tests**

- `testDropTableAcceptsCapitalizedPurgeRequested` walks `true, false,
True, False, TRUE, FALSE, tRuE, 1, 0` and the empty value against a
fresh table each, and asserts the table is gone afterwards.
- `testDropTableRejectsNonBooleanPurgeRequested` asserts `yes`, `purge`
and `2` are a 400 with the exact message **and that the table is still
there** -- a destructive endpoint must not act on input it refused.

Verified both directions: with the service file from `main` both new
tests fail (`expected: 204 but was: 400` for `True`, and Armeria's
message for `yes`); with the change all 19 tests in the class pass.

```
sbt "server/testOnly io.unitycatalog.server.service.IcebergRestCatalogTest"
```

End-to-end against a local server with pyiceberg 0.12.0: `drop_table`
and `purge_table` both fail with the 400 above on `main` and both
succeed on this branch, with the table gone from `list_tables`
afterwards.

**Backward compatibility**: the set of accepted values grows and nothing
that worked stops working. The only change for an existing caller is the
message text on a non-boolean value (same 400).

Signed-off-by: Noritaka Sekiyama <[email protected]>
newfront pushed a commit to newfront/unitycatalog that referenced this pull request Sep 24, 2026
…geRequested (unitycatalog#1890)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated (nothing in `docs/` describes this parameter)

**Description of changes**

`pyiceberg` cannot drop an Iceberg table through Unity Catalog today.
Both of its entry points fail with a 400:

```
>>> catalog.drop_table(("my_schema", "t"))    # sends purgeRequested=False
pyiceberg.exceptions.BadRequestError: BadRequestException: Can't convert 'False' to type 'Boolean'.
>>> catalog.purge_table(("my_schema", "t"))   # sends purgeRequested=True
pyiceberg.exceptions.BadRequestError: BadRequestException: Can't convert 'True' to type 'Boolean'.
```

pyiceberg hands a Python `bool` straight to `requests`
(`params={"purgeRequested": purge_requested}` in
`pyiceberg/catalog/rest/__init__.py`), and `requests` renders it `True`
/ `False`. Armeria converts a `Boolean` parameter through a fixed table
of `true|TRUE|1` and `false|FALSE|0` (`StringUtil.stringToBoolean`), so
neither spelling converts, and `AnnotatedValueResolver` is in an
`internal` package, so the conversion is not pluggable. The Iceberg REST
spec types this parameter `boolean` with `default: false`, so a
capitalized spelling is a valid request and dropping the table is the
correct answer.

This is the second of the two interop checks unitycatalog#1696 named as open when
the native Iceberg write endpoints landed; the first (HEAD stalling) was
fixed in unitycatalog#1801.

**Technical changes**

- `IcebergRestCatalogService.dropTable` binds `purgeRequested` as a
`String` and validates it, reading `true` and `false` without regard to
case.
- The spellings Armeria already accepted, `1` and `0` included, keep
working, so the accepted set only grows. A value that is not a boolean
at all is still a 400, now with a message that names the offending value
(`Invalid purgeRequested: yes. It must be true or false.`) instead of
Armeria's `Can't convert 'yes' to type 'Boolean'.`
- The value itself stays unused: purging is not implemented, and
`dropTable` removes the table either way, as before.

**Two choices worth a reviewer's opinion**

- The helper validates rather than parses. Returning an
`Optional<Boolean>` no caller reads would be new surface with nothing
behind it, so the value is dropped after the check; when purge is
implemented this becomes a parse.
- Only the Iceberg endpoint is fixed here. Ten `Optional<Boolean>` query
parameters on the native surface (`force` on the catalog, schema,
function, model, credential and external-location deletes, plus
`include_browse`, `omit_properties`, `omit_columns`) reject `True` the
same way -- measured on a local server. That is the native API's own
contract rather than an Iceberg interop bug, and this repo's generated
Python client is unaffected because it lowercases booleans, so I left it
out and will file it separately.

**Tests**

- `testDropTableAcceptsCapitalizedPurgeRequested` walks `true, false,
True, False, TRUE, FALSE, tRuE, 1, 0` and the empty value against a
fresh table each, and asserts the table is gone afterwards.
- `testDropTableRejectsNonBooleanPurgeRequested` asserts `yes`, `purge`
and `2` are a 400 with the exact message **and that the table is still
there** -- a destructive endpoint must not act on input it refused.

Verified both directions: with the service file from `main` both new
tests fail (`expected: 204 but was: 400` for `True`, and Armeria's
message for `yes`); with the change all 19 tests in the class pass.

```
sbt "server/testOnly io.unitycatalog.server.service.IcebergRestCatalogTest"
```

End-to-end against a local server with pyiceberg 0.12.0: `drop_table`
and `purge_table` both fail with the 400 above on `main` and both
succeed on this branch, with the table gone from `list_tables`
afterwards.

**Backward compatibility**: the set of accepted values grows and nothing
that worked stops working. The only change for an existing caller is the
message text on a non-boolean value (same 400).

Signed-off-by: Noritaka Sekiyama <[email protected]>
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.

5 participants