bharos commented on issue #10766: URL: https://github.com/apache/gravitino/issues/10766#issuecomment-4246543692
Implementation approach The fix touches IcebergTableHookDispatcher in two places: 1. createTable() — When CreateTableRequest.stageCreate() is true, skip importTableAndSetOwner(). The table doesn't physically exist in the catalog yet (it's only staged in memory with vended credentials), so attempting to load it would throw NoSuchTableException. 2. updateTable() — This is where the staged table gets committed. However, updateTable is also called for regular operations like property changes, so we can't unconditionally import/set ownership here. To distinguish staged create commits from regular updates, we check for UpdateRequirement.AssertTableDoesNotExist in the request's requirements list. This is the canonical signal for staged create commits in the Iceberg REST protocol: RESTSessionCatalog.createTransaction() creates a RESTTableOperations with [UpdateType.CREATE](https://github.com/apache/iceberg/blob/87c743463b6311f2412e1addf19cf204c1b79e3d/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java#L1021) RESTTableOperations.commit() switches on UpdateType.CREATE → [calls UpdateRequirements.forCreateTable()](https://github.com/apache/iceberg/blob/87c743463b6311f2412e1addf19cf204c1b79e3d/core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java#L171) → which produces [AssertTableDoesNotExist](https://github.com/apache/iceberg/blob/87c743463b6311f2412e1addf19cf204c1b79e3d/core/src/main/java/org/apache/iceberg/UpdateRequirements.java#L35) Regular updates use UpdateType.SIMPLE → UpdateRequirements.forUpdateTable() → produces [AssertTableUUID] Iceberg's own server-side implementation uses the exact same check — [CatalogHandlers.isCreate() ](https://github.com/apache/iceberg/blob/87c743463b6311f2412e1addf19cf204c1b79e3d/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java#L580)checks request.requirements().stream().anyMatch(AssertTableDoesNotExist.class::isInstance) to branch between the create and update paths. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
