-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: support for parameters in LIKE and RLIKE #138051
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
Merged
cimequinox
merged 33 commits into
elastic:main
from
cimequinox:esql_like_parameters_131356
Nov 26, 2025
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
c9010a9
Parser and ExpressionBuilder changes for like parameters
cimequinox 21b1e33
Documentation examples for like parameters
cimequinox 4533f2f
Unit tests for like parameters
cimequinox 9dd80b9
Add EsqlCapabilities LIKE_PARAMETER_SUPPORT
cimequinox 61155c7
Add yamlRestTest for like with parameters
cimequinox 52b661f
Generated files
cimequinox 82ec663
Tests check for LIKE_PARAMETER_SUPPORT capability
cimequinox cb44603
[CI] Auto commit changes from spotless
b4b732e
Handle RLIKE param, LIKE param list, RLIKE param list
cimequinox dddd2cc
StatementParserTests for RLIKE, LIKE list, RLIKE list
cimequinox adfca6b
AnalyzerTests for LIKE, LIKE list, RLIKE, RLIKE list
cimequinox be2f8b1
Add yamlRestTest for LIKE, RLIKE and error case for LIKE list
cimequinox 0402aca
Add RestEsqlTestCase for LIKE, RLIKE and LIKE list
cimequinox ff05c50
Fix typo in docs and explain why we use an inline example instead of …
cimequinox 15af547
Generated files
cimequinox b284375
Update docs/changelog/138051.yaml
cimequinox ac4d107
Include anonymous and positional parameters in tests
cimequinox 2a065a8
Collect parameter errors instead of immediately throwing them
cimequinox 14a1592
Use anonymous and positional parameters in RestEsqlTestCase and also …
cimequinox cd652ec
[CI] Auto commit changes from spotless
d4f112f
Update x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/…
cimequinox e0b2320
Update x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/…
cimequinox 495fd39
Move stringOrParameter to EsqlBaseParser.g4
cimequinox d9dbc7f
Generated Files
cimequinox 09bca88
Generated docs
cimequinox df170f2
Refactor stringToStringOrParam to reuse visitParam via a private help…
cimequinox 53573e3
Merge branch 'main' into esql_like_parameters_131356
cimequinox 7e07be0
Merge branch 'main' into esql_like_parameters_131356
cimequinox b9470d9
Generated files
cimequinox d98597e
Move code for ease of review, add comments, improve naming of source …
cimequinox 411de4c
Merge branch 'main' into esql_like_parameters_131356
cimequinox c486dbc
Merge branch 'main' into esql_like_parameters_131356
cimequinox a6c96f6
Merge branch 'main' into esql_like_parameters_131356
cimequinox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 138051 | ||
| summary: Support for parameters in LIKE and RLIKE | ||
| area: ES|QL | ||
| type: enhancement | ||
| issues: [] |
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
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
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
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.interp
Large diffs are not rendered by default.
Oops, something went wrong.
14 changes: 7 additions & 7 deletions
14
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Could we add a few more tests that cover positional parameters (fields like ?1) and anonymous parameters (fields like ?)? We ran into issues with named parameters with array value (for example, {"pattern": ["a", "b"]}) previously, so it would be great to include some validation tests for that case as well.
Uh oh!
There was an error while loading. Please reload this page.
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 will add some use of positional and anonymous parameters to the tests.I've changed the StatementParserTests, the AnalyzerTests and the RestEsqlTestCase tests to make use of anonymous, positional and named parameters.
It did not occur to me to consider array values but they could be useful.
For example in addition to
field LIKE (?p1, ?p2)with params{"p1": "a*", "p2": "b*"}we could allow
field LIKE ?parraywith params{"parray": ["a*", "b*"]}but I can imagine this could get complex if we allow both.
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.
Yes, supporting array parameters could add extra complexity, we got a similar request to support array parameters for inlist predicate previously, and it is not supported yet, so it is not required for this PR, making sure clear error messages are returned is good.
Uh oh!
There was an error while loading. Please reload this page.
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've updated the PR description suggesting we consider array parameter support in a followup change.
Uh oh!
There was an error while loading. Please reload this page.
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.
Using the base_conversion index out of convenience, I ran a few queries passing arrays as parameters and noticed some curious behavior.
but this array query returns no results without generating any error
looking at the plan for each, the first becomes
but the second becomes
A simple
WHERE string LIKE ?patternwith"params": [{"pattern" : "f*"}]becomesI think in the array case it slips by because the "type" of the array is the type of the first element so it gets passed farther than expected.
This PR needs a little more error checking to properly prohibit array valued parameters and generate a useful error.
Uh oh!
There was an error while loading. Please reload this page.
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've added an invalidListParameter function to explicitly check for list parameters and a test to verify they are prohibited in LIKE/RLIKE expressions for now.
With this change the query which previously passed along the stringified list
now fails as expected.