ESQL: Fix case insensitive comparisons to ""#127532
Merged
nik9000 merged 8 commits intoelastic:mainfrom Apr 30, 2025
Merged
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
Collaborator
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Collaborator
|
Hi @nik9000, I've created a changelog YAML for you. |
nik9000
commented
Apr 29, 2025
| 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(); |
Member
Author
There was a problem hiding this comment.
_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.
idegtiarenko
approved these changes
Apr 30, 2025
luigidellaquila
approved these changes
Apr 30, 2025
Contributor
luigidellaquila
left a comment
There was a problem hiding this comment.
Good catch! LGTM
Member
Author
It was all randomized testing! |
nik9000
added a commit
to nik9000/elasticsearch
that referenced
this pull request
May 28, 2025
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
nik9000
added a commit
to nik9000/elasticsearch
that referenced
this pull request
May 28, 2025
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
Member
Author
elasticsearchmachine
pushed a commit
that referenced
this pull request
May 28, 2025
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
elasticsearchmachine
pushed a commit
that referenced
this pull request
May 28, 2025
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
fieldis not indexed or is atextfield.Closes #127431