diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListAllTags.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListAllTags.java index fa6c74c7afa..cded12808d9 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListAllTags.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListAllTags.java @@ -53,7 +53,7 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = String.join(",", tags); + String all = tags.length == 0 ? "No tags exist." : String.join(",", tags); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogs.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogs.java index e6aaf811ec9..eb9c960b14e 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogs.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogs.java @@ -49,7 +49,11 @@ public void handle() { try { GravitinoClient client = buildClient(metalake); catalogs = client.listCatalogsInfo(); - output(catalogs); + if (catalogs.length == 0) { + System.out.println("No catalogs exist."); + } else { + output(catalogs); + } } catch (NoSuchMetalakeException err) { exitWithError(ErrorMessages.UNKNOWN_METALAKE); } catch (Exception exp) { diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesets.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesets.java index 34839f683c5..d00ba3e6ba5 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesets.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesets.java @@ -71,7 +71,7 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = Joiner.on(",").join(filesets); + String all = filesets.length == 0 ? "No filesets exist." : Joiner.on(",").join(filesets); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java index fd9009a755a..a517b4daed8 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java @@ -53,7 +53,7 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = String.join(",", groups); + String all = groups.length == 0 ? "No groups exist." : String.join(",", groups); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListMetalakes.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListMetalakes.java index ee5ac81d646..b2388e5cd3d 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListMetalakes.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListMetalakes.java @@ -43,7 +43,11 @@ public void handle() { try { GravitinoAdminClient client = buildAdminClient(); metalakes = client.listMetalakes(); - output(metalakes); + if (metalakes.length == 0) { + System.out.println("No metalakes exist."); + } else { + output(metalakes); + } } catch (Exception exp) { exitWithError(exp.getMessage()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListRoles.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListRoles.java index a7bb1cd20f7..2ecb35bd093 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListRoles.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListRoles.java @@ -53,7 +53,7 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = String.join(",", roles); + String all = roles.length == 0 ? "No roles exist." : String.join(",", roles); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java index cf5fe487cc8..110a6477a62 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java @@ -60,7 +60,7 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = Joiner.on(",").join(schemas); + String all = schemas.length == 0 ? "No schemas exist." : Joiner.on(",").join(schemas); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTables.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTables.java index e6afb9b51c0..41a71e87c00 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTables.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTables.java @@ -61,7 +61,10 @@ public void handle() { tableNames.add(tables[i].name()); } - String all = Joiner.on(System.lineSeparator()).join(tableNames); + String all = + tableNames.isEmpty() + ? "No tables exist." + : Joiner.on(System.lineSeparator()).join(tableNames); System.out.println(all.toString()); } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTopics.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTopics.java index af4cc217713..a2da6a69ad7 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTopics.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTopics.java @@ -66,7 +66,10 @@ public void handle() { exitWithError(exp.getMessage()); } - String all = Joiner.on(",").join(Arrays.stream(topics).map(topic -> topic.name()).iterator()); + String all = + topics.length == 0 + ? "No topics exist." + : Joiner.on(",").join(Arrays.stream(topics).map(topic -> topic.name()).iterator()); System.out.println(all); } }