This is an automated email from the ASF dual-hosted git repository.
jmclean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new f4a0ebb85c [#6356] improve(CLI): Add tag support for model in CLI
(#6360)
f4a0ebb85c is described below
commit f4a0ebb85cf8c12da486bc63a0e02b19e86298b7
Author: Lord of Abyss <[email protected]>
AuthorDate: Thu Feb 6 11:59:15 2025 +0800
[#6356] improve(CLI): Add tag support for model in CLI (#6360)
### What changes were proposed in this pull request?
Add tag support for model in CLI.
1. `UntagEntity`
2. `TagEntity`
3. `ListEntityTags`
The logic for handling models in these three methods has been added.
need to add the processing logic to the `RemoveAllTags` method.
### Why are the changes needed?
Fix: #6356
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
local test.
---
.../gravitino/cli/commands/RemoveAllTags.java | 68 +++++++++++++++++-----
1 file changed, 54 insertions(+), 14 deletions(-)
diff --git
a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveAllTags.java
b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveAllTags.java
index 5221100a8e..9c774dfaac 100644
---
a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveAllTags.java
+++
b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveAllTags.java
@@ -20,17 +20,24 @@
package org.apache.gravitino.cli.commands;
import org.apache.gravitino.Catalog;
-import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.Schema;
import org.apache.gravitino.cli.AreYouSure;
import org.apache.gravitino.cli.ErrorMessages;
import org.apache.gravitino.cli.FullName;
+import org.apache.gravitino.cli.utils.FullNameUtil;
import org.apache.gravitino.client.GravitinoClient;
import org.apache.gravitino.exceptions.NoSuchCatalogException;
import org.apache.gravitino.exceptions.NoSuchMetalakeException;
import org.apache.gravitino.exceptions.NoSuchSchemaException;
import org.apache.gravitino.exceptions.NoSuchTableException;
+import org.apache.gravitino.file.Fileset;
+import org.apache.gravitino.file.FilesetCatalog;
+import org.apache.gravitino.messaging.Topic;
+import org.apache.gravitino.messaging.TopicCatalog;
+import org.apache.gravitino.model.Model;
+import org.apache.gravitino.model.ModelCatalog;
import org.apache.gravitino.rel.Table;
+import org.apache.gravitino.rel.TableCatalog;
/* Removes all the tags of an entity. */
public class RemoveAllTags extends Command {
@@ -66,21 +73,54 @@ public class RemoveAllTags extends Command {
try {
GravitinoClient client = buildClient(metalake);
- // TODO fileset and topic
- if (name.hasTableName()) {
+
+ if (name.getLevel() == 3) {
String catalog = name.getCatalogName();
- String schema = name.getSchemaName();
- String table = name.getTableName();
- Table gTable =
- client
- .loadCatalog(catalog)
- .asTableCatalog()
- .loadTable(NameIdentifier.of(schema, table));
- tags = gTable.supportsTags().listTags();
- if (tags.length > 0) {
- gTable.supportsTags().associateTags(null, tags);
+ Catalog catalogObject = client.loadCatalog(catalog);
+ switch (catalogObject.type()) {
+ case RELATIONAL:
+ entity = "table";
+ TableCatalog tableCatalog = catalogObject.asTableCatalog();
+ Table gTable = tableCatalog.loadTable(FullNameUtil.toTable(name));
+ tags = gTable.supportsTags().listTags();
+ if (tags.length > 0) {
+ gTable.supportsTags().associateTags(null, tags);
+ }
+ break;
+
+ case MODEL:
+ entity = "model";
+ ModelCatalog modelCatalog = catalogObject.asModelCatalog();
+ Model gModel = modelCatalog.getModel(FullNameUtil.toModel(name));
+ tags = gModel.supportsTags().listTags();
+ if (tags.length > 0) {
+ gModel.supportsTags().associateTags(null, tags);
+ }
+ break;
+
+ case FILESET:
+ entity = "fileset";
+ FilesetCatalog filesetCatalog = catalogObject.asFilesetCatalog();
+ Fileset gFileset =
filesetCatalog.loadFileset(FullNameUtil.toFileset(name));
+ tags = gFileset.supportsTags().listTags();
+ if (tags.length > 0) {
+ gFileset.supportsTags().associateTags(null, tags);
+ }
+ break;
+
+ case MESSAGING:
+ entity = "topic";
+ TopicCatalog topicCatalog = catalogObject.asTopicCatalog();
+ Topic gTopic = topicCatalog.loadTopic(FullNameUtil.toTopic(name));
+ tags = gTopic.supportsTags().listTags();
+ if (tags.length > 0) {
+ gTopic.supportsTags().associateTags(null, tags);
+ }
+ break;
+
+ default:
+ break;
}
- entity = table;
} else if (name.hasSchemaName()) {
String catalog = name.getCatalogName();
String schema = name.getSchemaName();