Skip to content

Commit

Permalink
[apache#6496] feat(CLI): Support plain 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 25, 2025
1 parent c536536 commit 8aa40bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ public String getOutput(Table table) {
.map(
column ->
COMMA_JOINER.join(
column.name(), column.dataType().simpleString(), column.comment()))
column.name(),
column.dataType().simpleString(),
column.autoIncrement(),
column.nullable(),
column.comment() == null ? "N/A" : column.comment()))
.collect(Collectors.toList());
output.append(NEWLINE_JOINER.join(columnOutput));
output.append(System.lineSeparator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ void testTableDetailsWithPlainFormat() {
PlainFormat.output(mockTable, mockContext);
String output = new String(outContent.toByteArray(), StandardCharsets.UTF_8).trim();
Assertions.assertEquals(
"id, integer, This is a int column\n" + "name, string, This is a string column", output);
"id, integer, true, false, This is a int column\n"
+ "name, string, false, true, This is a string column",
output);
}

@Test
Expand All @@ -146,16 +148,6 @@ void testListTableWithPlainFormat() {
Assertions.assertEquals("table1\n" + "table2", output);
}

@Test
void testTableDetailsWithAuditWithPlainFormat() {
CommandContext mockContext = getMockContext();
Table mockTable = getMockTable();
PlainFormat.output(mockTable, mockContext);
String output = new String(outContent.toByteArray(), StandardCharsets.UTF_8).trim();
Assertions.assertEquals(
"id, integer, This is a int column\n" + "name, string, This is a string column", output);
}

@Test
void testOutputWithUnsupportType() {
CommandContext mockContext = getMockContext();
Expand Down

0 comments on commit 8aa40bf

Please sign in to comment.