World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#6356] improve(CLI): Add tag support for model in CLI (#6360)
Lord of Abyssf4a0ebb85cf8
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.javaindex 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();