Skip to content

Commit

Permalink
[apache#6493] feat(CLI): Support table format output for Schema and T…
Browse files Browse the repository at this point in the history
…able command

fix some bugs.
  • Loading branch information
Abyss-lord committed Feb 22, 2025
1 parent 9666434 commit 2b67d23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.gravitino.cli.commands;

import org.apache.gravitino.Catalog;
import org.apache.gravitino.Schema;
import org.apache.gravitino.cli.CommandContext;
import org.apache.gravitino.cli.ErrorMessages;
import org.apache.gravitino.client.GravitinoClient;
Expand Down Expand Up @@ -48,9 +50,12 @@ public ListSchema(CommandContext context, String metalake, String catalog) {
@Override
public void handle() {
String[] schemas = new String[0];
Catalog tableCatalog = null;

try {
GravitinoClient client = buildClient(metalake);
schemas = client.loadCatalog(catalog).asSchemas().listSchemas();
tableCatalog = client.loadCatalog(catalog);
schemas = tableCatalog.asSchemas().listSchemas();
} catch (NoSuchMetalakeException err) {
exitWithError(ErrorMessages.UNKNOWN_METALAKE);
} catch (NoSuchCatalogException err) {
Expand All @@ -64,6 +69,11 @@ public void handle() {
return;
}

printResults(schemas);
Schema[] schemaObjects = new Schema[schemas.length];
for (int i = 0; i < schemas.length; i++) {
schemaObjects[i] = tableCatalog.asSchemas().loadSchema(schemas[i]);
}

printResults(schemaObjects);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ public String getOutput(Table table) {
columnType.addCell(column.dataType().simpleString());
columnAutoIncrement.addCell(column.autoIncrement());
columnNullable.addCell(column.nullable());
columnComment.addCell(column.comment().isEmpty() ? "N/A" : column.comment());
columnComment.addCell(
column.comment() == null || column.comment().isEmpty() ? "N/A" : column.comment());
}

return getTableFormat(
Expand Down

0 comments on commit 2b67d23

Please sign in to comment.