-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cli): Improve CLI commands with better error handling and output formatting #6573
base: main
Are you sure you want to change the base?
refactor(cli): Improve CLI commands with better error handling and output formatting #6573
Conversation
@justinmclean it was taking too long for me as there where multiple files but finally made my way, now it's up to you, you may go through the changes and feel free to mention also added comments where i feel it should be there for better readability. |
@yuqi1129 need your review on this PR. |
Got |
@yuqi1129 That was too quick, Thanks!! |
@yuqi1129 need your review on this PR again |
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogAudit.java
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListColumns.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesetProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListMetalakeProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchemaProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTopicProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/TableAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/TopicDetails.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListColumns.java
Outdated
Show resolved
Hide resolved
@justinmclean @tengqm tried to fix and resolve as suggested can just go through it ones also removed what i feel is not needed. |
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListCatalogProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListColumns.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UserDetails.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UserDetails.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ModelDetails.java
Outdated
Show resolved
Hide resolved
@justinmclean tried to fix all return statement, using it was my best practice but for this repo as u said we don't generally need so removed apart from that fixed all if statements outside the try block. Also thankyouuu! for giving reviews always as there are multiples files so this is taking way more time. |
try { | ||
GravitinoClient client = buildClient(metalake); | ||
gCatalog = client.loadCatalog(catalog); | ||
Catalog gCatalog = client.loadCatalog(catalog); | ||
} catch (NoSuchMetalakeException err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh No. This code won't work.
Checking gCatalog on line 54 before it is declared on line 59?
Throw NoSuchMetalakeException while metalake is used on line 52?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will loadCatalog throw NoSuchMetalakeException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On checking loadCatalog it will generally not throw NoSuchMetalakeException, and hence removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code buildClient(metalake);
may throw this exception, right?
You moved that line out of the try block for unknown reason.
Now you know why I'm concerned?
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListFilesetProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/TableAudit.java
Outdated
Show resolved
Hide resolved
@tengqm made relevant changes. |
Two points here:
|
@tengqm Apologies for any confusion. As Justin mentioned, the decision was to remove the return statement, and I’ve tried to remove it from almost all files. I didn’t mean to take your feedback the wrong way—I truly appreciate the review. I might have missed checking all files since I’m currently in the middle of my university exams while still staying active in open-source contributions. I’ll make sure to correct it properly. Would it be fine if I just remove the return statement from all files to ensure consistency? |
@tengqm Just to confirm, should I go ahead and remove the return statement from all cases, including if statements? |
Yup. If the decision was that 'return' is unnecessary, please remove them all. |
59fb7e3
to
42ca8c9
Compare
.append(","); | ||
all.append(column.comment() != null ? column.comment() : "N/A").append(","); | ||
all.append(column.nullable() ? "true" : "false").append(","); | ||
all.append(column.autoIncrement() ? "true" : "false"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this column is okay and consistent with other format of outputs.
f013623
to
349b343
Compare
@tengqm do we need any changes?? |
printInformation("No tables exist."); | ||
return; | ||
} | ||
if (tables == null || tables.length == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code should be outside the try block
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListTagProperties.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/ModelDetails.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaAudit.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UserDetails.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/UserDetails.java
Outdated
Show resolved
Hide resolved
c7bb843
to
108c398
Compare
@jerryshao i really appreciate your review on this PR. |
@Brijeshthummar02, there are still some outstanding, unaddressed comments. You have also resolved several issues without fixing them. It's getting there, but I think it still needs a little work. My main concern is that the added |
What changes were proposed in this pull request?
This PR enhances multiple CLI commands by improving error handling, resource management, and output formatting. The following changes were made:
Why are the changes needed?
These improvements ensure that CLI commands provide more reliable feedback to users, prevent unhandled exceptions, and improve resource management. The changes also enhance maintainability and debugging for developers.
Fix: #6528
Does this PR introduce any user-facing change?
Yes, the following user-facing changes are introduced: