-
Notifications
You must be signed in to change notification settings - Fork 170
[Enhancement] Add error handling for known limitation of sql JOIN
#4344
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
base: main
Are you sure you want to change the base?
[Enhancement] Add error handling for known limitation of sql JOIN
#4344
Conversation
Signed-off-by: Jialiang Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
JOIN
JOIN
Signed-off-by: Jialiang Liang <[email protected]>
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.
A few suggestions -- I think this could be designed better if changing JoinSelect
doesn't cause cascading breakage, otherwise this approach is fine.
throws SqlParseException { | ||
String errorMessage = | ||
"JOIN queries do not support aggregations on the joined result. For more information, see" | ||
+ " https://docs.opensearch.org/latest/search-plugins/sql/limitation/#join-does-not-support-aggregations-on-the-joined-result"; |
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.
suggestion: Can we fetch the cluster version and use it instead of latest
?
If we ever fix this constraint, this error message will be invalid on all the older versions that output it
updateJoinLimit(query.getLimit(), joinSelect); | ||
|
||
// todo: throw error feature not supported: no group bys on joins ? | ||
validateJoinWithoutAggregations(query); |
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.
suggestion (if-minor): Should we move a lot of this logic to the construction of the JoinSelect
?
Seems weird to construct the object and then use its setters to fill in everything, instead of just passing in the subquery block and letting it figure itself out. This also would guarantee that this validation is applied everywhere that JoinSelect is constructed.
/** JOIN Aggregation Validation Tests */ | ||
private void expectJoinAggregationException() { | ||
thrown.expect(SqlParseException.class); | ||
thrown.expectMessage("JOIN queries do not support aggregations on the joined result."); |
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.
todo: This is a hard-coded copy of the validation's private error message
We should just make it public & reference it like we do with most of the other strings. I've had a few cases now of trying to clarify error messages and getting several pointless test failures for it
|
||
@Test | ||
public void joinWithGroupByShouldThrowException() throws SqlParseException { | ||
expectJoinAggregationException(); |
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.
praise: Nice idea to make the exception expectation a shared function
I probably would have done a bunch of thrown.expect
&& thrown.expectMessage(ERROR_MSG)
copies, this is nicer
} | ||
|
||
@Test | ||
public void joinWithSumFunctionShouldThrowException() throws SqlParseException { |
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.
suggestion: Since we're just leaning on Select.AGGREGATE_FUNCTIONS
, we could reduce all these aggregation cases to a single table-driven test
Signed-off-by: Jialiang Liang [email protected]
Description
Better error handling for known limitation of sql JOIN
example:
Related Issues
JOIN
query limitation #4058Check List
--signoff
or-s
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.