-
Notifications
You must be signed in to change notification settings - Fork 25.6k
SQL: Fix null handling for IN => painless script #35124
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
Conversation
Include `null` literals when generating the painless script for `IN` expressions. Previously, they were skipped, because of an issue that had been fixed with elastic#35108. Fixes: elastic#35122
|
Pinging @elastic/es-search-aggs |
astefan
left a comment
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
|
retest this please |
costin
left a comment
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 script generation should delegate to InternalSqlScriptUtils not replicate the code.
| if (value.dataType() == DataType.NULL) { | ||
| return null; | ||
| } | ||
| if (list.size() == 1 && list.get(0).dataType() == DataType.NULL) { |
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 does this line do?
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.
it's the same optimization to fold to LocalExec. I can merge the ifs
| ScriptTemplate rightScript = asScript((Expression) valueFromList); | ||
| sj.add(scriptPrefix + rightScript.template()); | ||
| rightParams.add(rightScript.params()); | ||
| if (valueFromList instanceof Expression) { |
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 don't think this block ever executing considering the values is a list of folded expressions and thus values.
| sj.add(scriptPrefix + rightScript.template()); | ||
| rightParams.add(rightScript.params()); | ||
| } else { | ||
| if (valueFromList instanceof 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.
The script should just delegate to InternalSqlScriptsUtils.in not duplicate the code inside the script.
| assertNull(translation.query); | ||
| AggFilter aggFilter = translation.aggFilter; | ||
| assertEquals("InternalSqlScriptUtils.nullSafeFilter(params.a0==10 || params.a0==20 || params.a0==30)", | ||
| assertEquals("InternalSqlScriptUtils.nullSafeFilter(" + |
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 should be nullSafeFilter(InternalSqlScriptUtils.in(params.a0, params) with the constants being sent as a params to the script
|
I realize this is impacted by #35055 but it makes the change set confusing. Could you please rebase this over that or potentially merge that first and the update this ticket. Thanks |
|
OK! Will merge the other PR first and adjust this based on the other. |
|
@costin updated on top of the #35055 and the fix is just to remove the null filtering: https://github.com/elastic/elasticsearch/pull/35124/files#diff-c67de98b2f74bb15fb8cdcbea8ef573cL112 |
|
Backported to |
|
Backported to |
Include
nullliterals when generating the painless script forINexpressions.Previously, they were skipped, because of an issue that has been fixed with #35108.
Fixes: #35122