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
SQL: Concat should be always not nullable #36601
Conversation
Pinging @elastic/es-search |
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.
I'd prefer to have an optimizer test for that, actually QueryFolder test to check that the concat is not eliminated because of the FoldNull() rule.
We can keep the integ test too, of course.
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.
+1 to what Marios said. The advantage of that unit tests is that it checks the behavior in isolation and thus we can identify in the future if there are any side effects.
run the gradle build tests 1 |
@astefan The test you added is also nice, but would be great to also add one similar to those: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/optimizer/OptimizerTests.java#L407 that checks that FoldNull() doesn't fold the concat() function to null when at least one null literal is involved. Sorry for not being more specific before and I confused you with mentioning the Thank you! |
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.
LGTM. Thx for the tests!
@@ -111,6 +112,8 @@ | |||
private static final Literal FOUR = L(4); | |||
private static final Literal FIVE = L(5); | |||
private static final Literal SIX = L(6); | |||
|
|||
private static final String EMPTY_STRING = ""; |
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.
Is it already available in TestUtils?
This PR fixes the CONCAT function case where, if one of the values is
null
, the function returnsnull
. Instead it should always considernull
as an empty string. Fixes #36169.