roryqi commented on code in PR #10834:
URL: https://github.com/apache/gravitino/pull/10834#discussion_r3166476336
##########
core/src/main/java/org/apache/gravitino/hook/ModelHookDispatcher.java:
##########
@@ -69,13 +74,23 @@ public Model registerModel(NameIdentifier ident, String
comment, Map<String, Str
Model model = dispatcher.registerModel(ident, comment, properties);
// Set the creator as owner of the model.
- OwnerDispatcher ownerManager =
GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- ownerManager.setOwner(
- ident.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(ident, Entity.EntityType.MODEL),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ OwnerDispatcher ownerManager =
GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the model name based on
catalog capabilities,
+ // so the entity is stored under the normalized identifier. Apply the
same normalization
+ // here so the owner is attached to the same identifier the manager
sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.MODEL,
GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent,
Entity.EntityType.MODEL),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception e) {
+ LOG.warn("Failed to set owner for model {}, model exists without owner",
ident, e);
Review Comment:
I prefer not catching the exceptions. We can modify this place after we have
a discussion conclusion.
--
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]