You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "cool9850311 (via GitHub)" <gi...@apache.org> on 2025/01/16 08:58:18 UTC
[PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
cool9850311 opened a new pull request, #6298:
URL: https://github.com/apache/gravitino/pull/6298
### What changes were proposed in this pull request?
1. Rename tag to a name already exists in the current metalake, it should return 409 instead of 500
2. The error message should show the correct conflict name
### Why are the changes needed?
Fix: #6254
### Does this PR introduce any user-facing change?
No
### How was this patch tested?
ut
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1922232109
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
If it is the `EntityAlreadyExistsException`, which could only happen when the new name and the old name are the same, so you don't have to get the new name for `TableChange`, you can use the `name` from the method.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1922243133
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
What you need to change it to change the exception only, no need to change the message.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1922232109
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
If it is the `EntityAlreadyExistsException`, which could only happen when the new name and the old name are the same, so you don't have to get the new name for `TableChange`, you can use the `name` from the method, which is the same.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1922232109
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
If it is the `EntityAlreadyExistsException`, which could only happen when the new name and the old name are the same, so you don't have to get the new name for `TableChange`, you can use the old `name` from the method, which is the same.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "cool9850311 (via GitHub)" <gi...@apache.org>.
cool9850311 commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1919869004
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
The updated Tag entity is being constructed within a deeply nested callback function, making it challenging to access (since the error occurs, the updated Tag entity cannot be retrieved as a return value). Alternatively, I could include the error name in the exception thrown by the TagMetaService.updateTag() method.
So I believe this alternative approach is simpler and more straightforward for retrieving the name.
In this case, if a TagAlreadyExistsException is triggered, the method will never return null. However, instead of returning null in cases where the method might be misused, it might be better to throw an error to explicitly handle such situations.
Which one do you prefer?
Get the name from the Exception or TagChange?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao closed pull request #6298: [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500
URL: https://github.com/apache/gravitino/pull/6298
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "cool9850311 (via GitHub)" <gi...@apache.org>.
cool9850311 commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1922250026
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
@danhuawang cc
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "cool9850311 (via GitHub)" <gi...@apache.org>.
cool9850311 commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1921999207
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
But the conflict old name in updateTag step is actually come from TagChange?
And WDYM passed in name here, I don't get it.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1919796615
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
You can get the new name from the updated tag entity, no need to do it here. Also, it is not proper to return null, which will be weird for the printed log.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#issuecomment-2597781685
Beside the code change here, I think also update the related openapi doc.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6254]Improve: Rename tag to a name already exists in the current metalake, it should return 409 instead of 500 [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #6298:
URL: https://github.com/apache/gravitino/pull/6298#discussion_r1921871848
##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -352,6 +352,15 @@ public String[] associateTagsForMetadataObject(
}));
}
+ private String getNewName(TagChange... changes) {
+ for (TagChange change : changes) {
+ if (change instanceof TagChange.RenameTag) {
+ return ((TagChange.RenameTag) change).getNewName();
+ }
+ }
+ return null;
Review Comment:
I think you make things complicated, if it is the name conflict, the old name and new name should be the same, you can use the `name` passed in. Both getting the name from `TagChange` and `Exception` are too complex and not necessary just for getting a name.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org