-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#3460] feat(api): Add API design for Tag system #3486
Conversation
api/src/main/java/com/datastrato/gravitino/SupportsCatalogs.java
Outdated
Show resolved
Hide resolved
api/src/main/java/com/datastrato/gravitino/SupportsMetalakes.java
Outdated
Show resolved
Hide resolved
* @param tagsToRemove The array of tag name to be removed from the entity. | ||
* @return The array of tag names that are associated with the entity. | ||
*/ | ||
String[] associateTags(String[] tagsToAdd, String[] tagsToRemove); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this method, the requestor need to know which tags are new, which are existed but to be removed, this might be a little complicated for the requestor; how about change it to "applyTags(String[] tags)", so that each time the requestor pass in a full set of the tags, no need to distinguish which are new and which are to be remove;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the current API, users still don't need to distinguish whether the tag is new or not. They can add all the tags they want to tagsToAdd
, I will handle this in the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, the backend will compare and recognize that, which is good for the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a tag appears in two arrays at the same time, what will be the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be no-op. Same as if we both enable setProperty
and removeProperty
on the same key for alterTable.
For snowflake, tag is related to the securable object. You can see https://docs.snowflake.com/en/user-guide/object-tagging
|
} | ||
|
||
/** @return The number of entities that are using this tag. */ | ||
int inUse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this method have a default implementation?
return usedEntities().length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
@shaofengshi @jerqi @mchades can you please review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM |
int inUse(); | ||
|
||
/** @return The list of objects that are using this tag. */ | ||
MetadataObject[] usedObjects(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about associatedObjects
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
/** The extended information of the tag. */ | ||
interface Extended { | ||
/** @return The number of objects that are using this tag. */ | ||
default int inUse() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inUse
seems a state. Could you give this a better name?
* @throws NoSuchTagException If the tag does not exist. | ||
* @throws IllegalArgumentException If the changes cannot be applied to the tag. | ||
*/ | ||
Tag alterTag(String name, TagChange... changes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use updateTag
? Snowflake use AlterTag
. Git uses UpdateTag
. All is ok for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with either, I have no strong preference.
* @return The tag. | ||
* @throws NoSuchTagException If the tag does not exist. | ||
*/ | ||
Tag getTag(String name) throws NoSuchTagException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need extended
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, there's no such requirement based on our UI requirement, I think we can add it later on.
I changed to |
Extended's
or we remove
Maybe I don't provide a enough proper solution, you can think a better solution. |
|
@jerqi please review again? |
/** The interface of the associated objects of the tag. */ | ||
interface AssociatedObjects { | ||
|
||
/** @return The number of objects that are associated with this Tag */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tag
-> tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this in the following PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just one nit.
### What changes were proposed in this pull request? This PR adds the API support for Tag system in Gravitino. ### Why are the changes needed? This is the first step to add a tag system. Fix: apache#3460 ### Does this PR introduce _any_ user-facing change? Yes. ### How was this patch tested? No. Test will be added later when implementing the logic.
What changes were proposed in this pull request?
This PR adds the API support for Tag system in Gravitino.
Why are the changes needed?
This is the first step to add a tag system.
Fix: #3460
Does this PR introduce any user-facing change?
Yes.
How was this patch tested?
No. Test will be added later when implementing the logic.