Skip to content

Commit

Permalink
[apache#5827] improvement(CLI): fix cli throws an obscure error
Browse files Browse the repository at this point in the history
Fix cli throws an obscure error when Delete a table with a missing table name.it should give clearer hints.
  • Loading branch information
Abyss-lord committed Dec 18, 2024
1 parent 5e9919e commit 9779886
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,29 @@ private void handleTableCommand() {
String schema = name.getSchemaName();

Command.setAuthenticationMode(auth, userName);
List<String> missingEntities =
Stream.of(
catalog == null ? CommandEntities.CATALOG : null,
schema == null ? CommandEntities.SCHEMA : null)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!missingEntities.isEmpty()) {
System.err.println("Missing required argument(s): " + Joiner.on(", ").join(missingEntities));
return;
}

if (CommandActions.LIST.equals(command)) {
List<String> missingEntities =
Stream.of(
metalake == null ? CommandEntities.METALAKE : null,
catalog == null ? CommandEntities.CATALOG : null,
schema == null ? CommandEntities.SCHEMA : null)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!missingEntities.isEmpty()) {
System.err.println(
"Missing required argument(s): " + Joiner.on(", ").join(missingEntities));
return;
}

newListTables(url, ignore, metalake, catalog, schema).handle();
return;
}

String table = name.getTableName();

if (Objects.isNull(table)) {
System.err.println("Missing required argument(s): " + CommandEntities.TABLE);
return;
}

if (CommandActions.DETAILS.equals(command)) {
if (line.hasOption(GravitinoOptions.AUDIT)) {
newTableAudit(url, ignore, metalake, catalog, schema, table).handle();
Expand Down

0 comments on commit 9779886

Please sign in to comment.