justinmclean commented on code in PR #6573:
URL: https://github.com/apache/gravitino/pull/6573#discussion_r1976572145


##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListColumns.java:
##########
@@ -51,18 +50,42 @@ public ListColumns(
   /** Displays the details of a table's columns. */
   @Override
   public void handle() {
-    Column[] columns = null;
-
     try {
       NameIdentifier name = NameIdentifier.of(schema, table);
-      columns = tableCatalog().loadTable(name).columns();
+      Column[] columns = tableCatalog().loadTable(name).columns();
+
+      if (columns != null && columns.length > 0) {
+        StringBuilder all = new StringBuilder();
+        
all.append("name,datatype,comment,nullable,auto_increment").append(System.lineSeparator());
+
+        for (Column column : columns) {
+          if (column == null) {
+            continue;
+          }
+
+          StringBuilder columnDetails = new StringBuilder();
+          columnDetails.append(column.name()).append(",");
+          columnDetails
+              .append(column.dataType() != null ? 
column.dataType().simpleString() : "UNKNOWN")
+              .append(",");
+          columnDetails.append(column.comment() != null ? column.comment() : 
"N/A").append(",");
+          columnDetails.append(column.nullable() ? "true" : 
"false").append(",");
+          columnDetails.append(column.autoIncrement() ? "true" : "false");
+
+          all.append(columnDetails).append(System.lineSeparator());
+        }
+
+        printResults(all.toString());
+      } else {
+        exitWithError("No columns found for the specified table.");
+      }
     } catch (NoSuchTableException noSuchTableException) {
       exitWithError(
-          ErrorMessages.UNKNOWN_TABLE + Joiner.on(".").join(metalake, catalog, 
schema, table));
+          ErrorMessages.UNKNOWN_TABLE
+              + " "
+              + Joiner.on(".").join(metalake, catalog, schema, table));
     } catch (Exception exp) {
-      exitWithError(exp.getMessage());
+      exitWithError("An error occurred while retrieving column details: " + 
exp.getMessage());

Review Comment:
   You need to use printResults to print out this information.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to