Skip to content

Commit

Permalink
fix command action and output format(CSV)
Browse files Browse the repository at this point in the history
  • Loading branch information
orenccl committed Nov 6, 2024
1 parent 58cf0db commit 30567dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ private void handleTableCommand() {

if (CommandActions.DETAILS.equals(command)) {
String table = name.getTableName();
new TableDetails(url, ignore, metalake, catalog, schema, table).handle();

if (line.hasOption(GravitinoOptions.INDEX)) {
new ListIndexes(url, ignore, metalake, catalog, schema, table).handle();
} else {
new TableDetails(url, ignore, metalake, catalog, schema, table).handle();
}
} else if (CommandActions.LIST.equals(command)) {
new ListTables(url, ignore, metalake, catalog, schema).handle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ListIndexes extends TableCommand {
* @param ignoreVersions If true don't check the client/server versions match.
* @param metalake The name of the metalake.
* @param catalog The name of the catalog.
* @param schema The name of the schenma.
* @param schema The name of the schema.
* @param table The name of the table.
*/
public ListIndexes(
Expand Down Expand Up @@ -66,17 +66,17 @@ public void handle() {

StringBuilder all = new StringBuilder();
for (Index index : indexes) {
// Flatten the two-dimensional array fieldNames to a single comma-separated string
// Flatten the two-dimensional array fieldNames to a single dot-separated string
List<String> flattenedFieldNames = new ArrayList<>();
for (String[] fieldHierarchy : index.fieldNames()) {
// Join nested fields (e.g., "a.b.c") for each inner array
flattenedFieldNames.add(String.join(".", fieldHierarchy));
}

String fields = String.join(", ", flattenedFieldNames);
String indexTitle = index.name();

all.append(indexTitle).append(": ").append(fields).append(System.lineSeparator());
String indexName = index.name();
for (String field : flattenedFieldNames) {
all.append(field).append(",").append(indexName).append(System.lineSeparator());
}
}

System.out.print(all);
Expand Down

0 comments on commit 30567dd

Please sign in to comment.