diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/PlainFormat.java b/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/PlainFormat.java index ac3db657817..0b91315cfb7 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/PlainFormat.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/PlainFormat.java @@ -95,7 +95,11 @@ public void output(Catalog[] catalogs) { static final class SchemaPlainFormat implements OutputFormat { @Override public void output(Schema schema) { - System.out.println(schema.name() + "," + schema.comment()); + if (schema == null) { + System.out.println("No schemas exist."); + } else { + System.out.println(schema.name() + "," + schema.comment()); + } } } } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/TableFormat.java b/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/TableFormat.java index 2be9820834d..ef87e79b531 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/TableFormat.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/outputs/TableFormat.java @@ -109,11 +109,15 @@ public void output(Catalog[] catalogs) { static final class SchemaTableFormat implements OutputFormat { @Override public void output(Schema schema) { - List headers = Arrays.asList("schema", "comment"); - List> rows = new ArrayList<>(); - rows.add(Arrays.asList(schema.name(), schema.comment() + "")); - TableFormatImpl tableFormat = new TableFormatImpl(); - tableFormat.print(headers, rows); + if (schema == null) { + System.out.println("No schemas exist."); + } else { + List headers = Arrays.asList("schema", "comment"); + List> rows = new ArrayList<>(); + rows.add(Arrays.asList(schema.name(), schema.comment() + "")); + TableFormatImpl tableFormat = new TableFormatImpl(); + tableFormat.print(headers, rows); + } } }