Repository navigation
Implement native Iceberg REST catalog write endpoints - #1696
Conversation
|
Thank you for this PR. Will take a look. |
|
I am still reviewing as it's a large PR implementing a major new feature. |
yili-db
left a comment
There was a problem hiding this comment.
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 { | |||
|
|
|||
There was a problem hiding this comment.
Just FYI I have a PR to consolidate this file into FileOperations so there will be conflict.
#1687
There was a problem hiding this comment.
Just FYI I have a PR to consolidate this file into
FileOperationsso 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(); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Catching this exception should be unnecessary. IcebergRestExceptionHandler should handle it already.
There was a problem hiding this comment.
Catching this exception should be unnecessary.
IcebergRestExceptionHandlershould 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. */ |
There was a problem hiding this comment.
Doesn't IcebergRestExceptionHandler already do this? If not, it should be fix instead.
There was a problem hiding this comment.
Doesn't
IcebergRestExceptionHandleralready 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) { | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Or is it actually caused by the bug being fixed by #1716?
There was a problem hiding this comment.
| yield String.format("decimal(%d,%d)", decimal.precision(), decimal.scale()); | ||
| } | ||
| case VARIANT -> "variant"; | ||
| default -> |
There was a problem hiding this comment.
Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
Add a TODO about supporting GEOMETRY/GEOGRAPHY, or a type specific error throwing.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
I've seen this pre-existing pattern of runAsync then join in this repo. But it is pointless.
There was a problem hiding this comment.
The pre-existing pattern of
runAsyncthenjoin... 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) { |
There was a problem hiding this comment.
Return a NormalizedURL to explicitly normalize the location.
There was a problem hiding this comment.
Return a
NormalizedURLto explicitly normalize the location.
Updated in 0cbbdf9. newMetadataLocation now returns NormalizedURL, and the metadata helper boundaries use it consistently.
5d21432 to
55b7fb8
Compare
|
@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
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 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. |
55b7fb8 to
0cbbdf9
Compare
|
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."); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
|
|
||
| @Override | ||
| protected BaseException toBaseException(Throwable cause) { | ||
| if (cause instanceof BaseException baseException) { |
There was a problem hiding this comment.
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:
-
For
BaseExceptionthrown by UC server code, we need to eventually map them into IcebergErrorResponse:
a. Make a newenum IcebergErrorType { NO_SUCH_TABLE(404, "NoSuchTableException"), ...}
b. EachErrorCodehas aDeltaErrorType deltaErrorTypedefined. A new fieldIcebergErrorType icebergErrorTypecan be added.
c. FinallyIcebergRestExceptionHandler.createErrorResponsecan useBaseExceptionand theErrorCodeinside to generate the correct response (existing impl is not correct). -
For Iceberg exceptions thrown by Iceberg code:
a. Convert them into correspondingBaseExceptionwith correctErrorCode(and correctIcebergErrorTypeinside).
b.IcebergRestExceptionHandler.createErrorResponsewrites out correct response the same way it does to server code thrown exceptions.
c. The current implementation ofIcebergRestExceptionHandler.getOriginalExceptionis lame as it simply finds a non-BaseExceptioneven 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) { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
An identical function lockTableForCommit exists in DeltaCommitRepository.
Please move it to RepositoryUtils so that you can reuse it.
openinx
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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( |
| node.put("name", field.name()); | ||
| node.set("type", typeJson(field.type())); | ||
| node.put("nullable", field.isOptional()); | ||
| node.set("metadata", MAPPER.createObjectNode()); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
| * 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) { |
|
|
||
| // Locations arrive both as plain paths and as file: URIs (matching what | ||
| // org.apache.iceberg.Files.localInput accepts). | ||
| private static File toLocalFile(String path) { |
| if (ucTableExists(catalog, namespace, request.name())) { | ||
| throw new AlreadyExistsException("Table already exists: %s.%s", namespace, request.name()); | ||
| } | ||
| metadataService.prepareTableLocation(tableMetadata); |
There was a problem hiding this comment.
This is pre-existing pattern:
void function(TableMetadata tableMetadata) {
doSomething(tableMetadata.location());
This is not good:
- From call site it's hard to understand that this function only needs the location, not anything else from
TableMetadata - 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 locationinstead 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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Please comment "No-op update"
|
|
||
| NormalizedURL newMetadataLocation = | ||
| MetadataService.newMetadataLocation( | ||
| updatedWithoutLocation, MetadataService.parseMetadataVersion(metadataLocation) + 1); |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
| // 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())) { |
There was a problem hiding this comment.
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]>
Signed-off-by: Kia Yun <[email protected]>
|
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. |
Signed-off-by: Yi Li <[email protected]>
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]>
|
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 |
tdas
left a comment
There was a problem hiding this comment.
Two comments... not blockers. Can be addressed in follow up PRs.
|
|
||
| private TableInfoDAO findTableOrThrow( | ||
| Session session, String catalogName, String schemaName, String tableName) { | ||
| UUID schemaId = |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
[AI-assisted]
we should never eat an error without logging, even best-effort cleanup. log at warn before swallowing.
|
@iamkiayun @dataders |
|
@yili-db WOO HOOOOOO! LFG! Thanks for taking this over the line! |
|
Thank you for the review, fixes, and merge, @yili-db! I really appreciate your guidance and help getting this contribution across the finish line. |
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]>
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]>
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]>
…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]>
…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]>
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 behindmainand its DCO check cannot be repaired by a third-party sign-off.Design decisions
ICEBERGtables are writable, while Delta UniForm tables remain read-only so Iceberg metadata cannot diverge from the Delta log.assert-createcommit materializes the table.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
serverShaded/assembly: passed.git diff --check: passed.Known interoperability checks
HEADendpoint with a real HTTP/1.1 Iceberg client; the Java integration suite passes, but an earlier local client probe could stall.purgeRequested; mixed-case values such asFalseremain an optional compatibility improvement.Related
Related: #3
Continuation of and implementation credit: #1618 by @dataders.
Post-deploy monitoring & validation
CommitFailedException,UPDATE_REQUIREMENT_CONFLICT,Failed to update Iceberg metadata location, credential-vending failures, and metadata read/write exceptions.PR checklist