-
Notifications
You must be signed in to change notification settings - Fork 202
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
Iceberg sink uses Parameters::get to ensure parameter definition exists #171
Iceberg sink uses Parameters::get to ensure parameter definition exists #171
Conversation
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.
Left a comment on the get
method. I don't think it actually requires any action but worth a discussion. Otherwise LGTM!
public Object get(String key, Object defaultValue) { | ||
Object value = defaultValue; |
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.
Do the semantics actually change with this? My initial read of the code says no, but if it does it may unintentionally impact other jobs.
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.
No, all branches will assign value so it's redundant to have an initial value.
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.
But it's cosmetic and I can revert that. Or better I can rewrite the whole function to use multiple returns.
try {
final Object value = get(key);
return value != null ? value : defaultValue;
} catch (ParameterException ex) {
return defaultValue;
}
* Get parameter value given key without validation. | ||
* | ||
* If the key is not defined or missing a provided value, the given default value will be returned. | ||
*/ | ||
public Object get(String key, Object defaultValue) { |
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.
What if you have a default value of null for the parameter and pass in a non-default value here as part of defaultValue? What should be the expected behavior? Can we also write tests for this to ensure the behavior remains consistent as we advance?
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.
That's a good question, but I really do not have the answer. The expected behavior depends on how it's now being used.
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.
According to this code snippet: https://github.com/Netflix/mantis/blob/master/mantis-runtime/src/main/java/io/mantisrx/runtime/parameter/ParameterUtils.java#L309-L315
It seems "default value of null for the parameter" means the parameter does not have a default value, i.e. missing in the definition. In that case, this get()
method is doing the right thing: return the provided defaultValue
. We can add a test for this.
Actually some existing tests fail due to the test parameter "state" is not complete - not including all parameter definitions. So we will need to update the test code a bit. I'll make this ready for review after I fix that failing test in a non-intrusive way. |
failing test seems unrelated. |
All green. I'll merge by EoD. CC: @sundargates |
mantis-runtime/build.gradle
Outdated
@@ -25,6 +25,7 @@ dependencies { | |||
api project(':mantis-common') | |||
api libraries.slf4jApi | |||
testImplementation libraries.junit4 | |||
testImplementation libraries.junitJupiter |
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.
isn't junit-jupiter meant for usage with junit5?
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.
Yes. It works just fine if we only use the utility assertion methods from Jupiter. But I agree, it's better not to mix JUnit 4 and Jupiter. I have written the assertThrows
in the testing code instead of pulling junitJupiter. I'll file a follow-up PR to upgrade JUnit 4 to Jupiter inmantis-runtime
module.
44f04e4
to
d1d0c25
Compare
|
Context
#170 (comment)
Checklist
./gradlew build
compiles code correctlyAdded new tests where applicable./gradlew test
passes all testsExtended README or added javadocs where applicableAdded copyright headers for new files fromCONTRIBUTING.md