-
Notifications
You must be signed in to change notification settings - Fork 25.4k
ESQL: Fix case insensitive comparisons to "" #127532
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
This fixes the compute engine side of case insensitive ==. You can trigger it by writing: ``` FROM foo | WHERE TO_LOWER(field) == "" ``` But *only* when we can't push the comparison to lucene - like if `field` is not indexed or is a `text` field. Closes elastic#127431
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Hi @nik9000, I've created a changelog YAML for you. |
@@ -83,6 +85,10 @@ protected TypeResolution resolveType() { | |||
} | |||
|
|||
public static Automaton automaton(BytesRef val) { | |||
if (val.length == 0) { | |||
// toCaseInsensitiveString doesn't match empty strings properly so let's do it ourselves | |||
return Automata.makeEmptyString(); |
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.
_search works around this as well with:
// check if valueForSearch is the same as an empty string
// if we have a length of zero, just do a regular term query
if (valueForSearch.length == 0) {
return termQuery(value, context);
}
Which makes sense. And it's slightly faster. Here, instead of doing a term query I just make an automata for the empty string. We are already pushing a proper term query using the _search infrastructure when possible.
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.
Good catch! LGTM
It was all randomized testing! |
This fixes the compute engine side of case insensitive ==. You can trigger it by writing: ``` FROM foo | WHERE TO_LOWER(field) == "" ``` But *only* when we can't push the comparison to lucene - like if `field` is not indexed or is a `text` field. Closes elastic#127431
This fixes the compute engine side of case insensitive ==. You can trigger it by writing: ``` FROM foo | WHERE TO_LOWER(field) == "" ``` But *only* when we can't push the comparison to lucene - like if `field` is not indexed or is a `text` field. Closes elastic#127431
This fixes the compute engine side of case insensitive ==. You can trigger it by writing: ``` FROM foo | WHERE TO_LOWER(field) == "" ``` But *only* when we can't push the comparison to lucene - like if `field` is not indexed or is a `text` field. Closes #127431
This fixes the compute engine side of case insensitive ==. You can trigger it by writing: ``` FROM foo | WHERE TO_LOWER(field) == "" ``` But *only* when we can't push the comparison to lucene - like if `field` is not indexed or is a `text` field. Closes #127431
This fixes the compute engine side of case insensitive ==. You can trigger it by writing:
But only when we can't push the comparison to lucene - like if
field
is not indexed or is atext
field.Closes #127431