You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "Abyss-lord (via GitHub)" <gi...@apache.org> on 2025/01/06 01:42:30 UTC
[PR] Refactor catalog validation [gravitino]
Abyss-lord opened a new pull request, #6104:
URL: https://github.com/apache/gravitino/pull/6104
### What changes were proposed in this pull request?
Add `validate` method to Command, and refactor the validation code of catalog.
### Why are the changes needed?
Fix: #6087
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
ut + local test
```bash
gcli catalog create -m demo_metalake --name test_catalog
# Missing --provider option.
gcli catalog set -m demo_metalake --name Hive_catalog
# Missing --property and --value options.
gcli catalog set -m demo_metalake --name Hive_catalog --property propertyA
# Missing --value option.
gcli catalog set -m demo_metalake --name Hive_catalog --value valA
# Missing --property option.
gcli catalog remove -m demo_metalake --name Hive_catalog
# Missing --property option.
```
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#discussion_r1903425817
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetCatalogProperty.java:
##########
@@ -74,4 +74,12 @@ public void handle() {
System.out.println(catalog + " property set.");
}
+
+ @Override
+ public Command validate() {
+ if (property == null && value == null) exitWithError("Missing --property and --value options.");
+ if (property == null) exitWithError(ErrorMessages.MISSING_PROPERTY);
+ if (value == null) exitWithError(ErrorMessages.MISSING_VALUE);
+ return this;
+ }
Review Comment:
Is this duplicated with the Metalake code? If so, it would be best to remove this duplication.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#discussion_r1903530053
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetCatalogProperty.java:
##########
@@ -74,4 +74,12 @@ public void handle() {
System.out.println(catalog + " property set.");
}
+
+ @Override
+ public Command validate() {
+ if (property == null && value == null) exitWithError("Missing --property and --value options.");
+ if (property == null) exitWithError(ErrorMessages.MISSING_PROPERTY);
+ if (value == null) exitWithError(ErrorMessages.MISSING_VALUE);
+ return this;
+ }
Review Comment:
Yes they could this method could be renamed and moved to Command and take a property and value parameter to check. Both the validate methods of metalake and catalog can then call it. Other future entities can also use it and that will cut down a lot on future duplicated code.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#issuecomment-2572256474
> LGTM thanks for this!
Hi @justinmclean , I just fix the ci error.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#discussion_r1903630275
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetCatalogProperty.java:
##########
@@ -74,4 +74,10 @@ public void handle() {
System.out.println(catalog + " property set.");
}
+
+ @Override
+ public Command validate() {
+ checkProperty(property, value);
+ return this;
+ }
Review Comment:
You could have checkProperty return this and change this to just `return checkProperty(property, value);` but either is probably fine
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Refactor catalog validation [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#issuecomment-2571930325
Hi @justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean merged PR #6104:
URL: https://github.com/apache/gravitino/pull/6104
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#issuecomment-2572180145
Hi @justinmclean , I’ve finished updating the code. Please take a look at the PR again when you have time.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "tengqm (via GitHub)" <gi...@apache.org>.
tengqm commented on PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#issuecomment-2571981122
LGTM, regarding the scope of this PR.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#discussion_r1903474608
##########
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java:
##########
@@ -234,10 +258,60 @@ void testSetCatalogPropertyCommand() {
"catalog",
"property",
"value");
+ doReturn(mockSetProperty).when(mockSetProperty).validate();
commandLine.handleCommandLine();
verify(mockSetProperty).handle();
}
+ @Test
+ void testSetCatalogPropertyCommandWithoutPropertyAndValue() {
+ Main.useExit = false;
+ SetCatalogProperty mockSetProperty =
+ spy(
+ new SetCatalogProperty(
+ GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", null, null));
+
+ assertThrows(RuntimeException.class, mockSetProperty::validate);
+ String errOutput = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
+ assertEquals("Missing --property and --value options.", errOutput);
Review Comment:
use ErrorMessages.xxx here
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on code in PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#discussion_r1903516865
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetCatalogProperty.java:
##########
@@ -74,4 +74,12 @@ public void handle() {
System.out.println(catalog + " property set.");
}
+
+ @Override
+ public Command validate() {
+ if (property == null && value == null) exitWithError("Missing --property and --value options.");
+ if (property == null) exitWithError(ErrorMessages.MISSING_PROPERTY);
+ if (value == null) exitWithError(ErrorMessages.MISSING_VALUE);
+ return this;
+ }
Review Comment:
@justinmclean hi Justin , IMHO, The code does not contain duplication; Metalake and Catalog are distinct entities and cannot be combined for handling `setProperty`.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#6087] fix(CLI): Refactor the validation logic of catalog [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6104:
URL: https://github.com/apache/gravitino/pull/6104#issuecomment-2572113634
> LGTM, regarding the scope of this PR.
Thank you very much.
--
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-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org