bharos commented on code in PR #10767:
URL: https://github.com/apache/gravitino/pull/10767#discussion_r3088764684
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableHookDispatcher.java:
##########
@@ -74,18 +75,26 @@ public LoadTableResponse updateTable(
UpdateTableRequest updateTableRequest) {
LoadTableResponse response =
dispatcher.updateTable(context, tableIdentifier, updateTableRequest);
- // Import the table and set ownership if the entity does not yet exist,
- // e.g. when committing a staged table create.
- try {
- EntityStore store = GravitinoEnv.getInstance().entityStore();
- NameIdentifier gravitinoTableId =
- IcebergIdentifierUtils.toGravitinoTableIdentifier(
- metalake, context.catalogName(), tableIdentifier);
- if (store != null && !store.exists(gravitinoTableId,
Entity.EntityType.TABLE)) {
- importTableAndSetOwner(context, tableIdentifier.namespace(),
tableIdentifier.name());
+ // Import the table and set ownership only when committing a staged table
create.
+ // A staged create commit is identified by the AssertTableDoesNotExist
requirement,
+ // which is set by UpdateRequirements.forCreateTable(). Regular updates
(e.g. property
+ // changes) do not carry this requirement, so we must not set ownership
for them even
+ // if the entity does not yet exist in the store.
+ boolean isStagedCreateCommit =
+ updateTableRequest.requirements().stream()
+
.anyMatch(UpdateRequirement.AssertTableDoesNotExist.class::isInstance);
+ if (isStagedCreateCommit) {
+ try {
+ EntityStore store = GravitinoEnv.getInstance().entityStore();
Review Comment:
Good point. Removed the store.exists() check — AssertTableDoesNotExist is
validated server-side by CatalogHandlers.create() before
dispatcher.updateTable() returns, so a duplicate request for an
already-committed table would throw CommitFailedException before our hook runs.
--
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]