[ES|QL] Support Named and Positional Parameters in EsqlQueryRequest#108421
[ES|QL] Support Named and Positional Parameters in EsqlQueryRequest#108421fang-xing-esql merged 38 commits intoelastic:mainfrom
Conversation
|
Hi @fang-xing-esql, I've created a changelog YAML for you. |
costin
left a comment
There was a problem hiding this comment.
Had a call with Fang about this.
FTR:
- mixing anonymous, named and ordinal params should not be allowed
- drop param type, we never use it/advertised it
- change List to a Params like object that returns the value of the given input param and does validation (for params to not be mixed, invalid ordinal, names, etc...)
libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java
Show resolved
Hide resolved
...ugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
bpintea
left a comment
There was a problem hiding this comment.
Had a first look, left some comments. I guess deciding to remove the type would make things clearer about how to progress.
...ugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
| final class RequestXContent { | ||
|
|
||
| private static final ConstructingObjectParser<TypedParamValue, Void> PARAM_PARSER = new ConstructingObjectParser<>( | ||
| private static class TempObjects { |
There was a problem hiding this comment.
This feels like a strange class to have. I guess if we get rid of the Params it might no longer be needed.
costin
left a comment
There was a problem hiding this comment.
This needs more work. In its current form it's breaking bwc since it changes the declaration for anonymous / un-named params from values: [1,2,3, "string"] to values: {[value:1], ...
This is of course a problem
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/Params.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
^
|
We will keep params as an array, since it is already an array, not an object. |
astefan
left a comment
There was a problem hiding this comment.
I haven't looked at the tests yet, but there are aspects that can be improved regarding the error messaging and, probably, the way these error messages are tested.
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/QueryParam.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/kibana-esql (ES|QL-ui) |
Thanks for reviewing @astefan ! The tests and messages are updated in the last commit, just need to clean up CI. |
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/QueryParams.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java
Outdated
Show resolved
Hide resolved
Thank you so much for thorough review @astefan !! I believe that the existing comments are all addressed. Please just let me know if I missed anything. |
astefan
left a comment
There was a problem hiding this comment.
For the ParsingExceptions that I was suggesting to have the location included in the message in EsqlParser, please also adjust any tests that assert those messages.
Once the latest comments are addressed, this LGTM. Thank you for your patience with all the comments I had.
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/QueryParams.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/QueryParams.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/QueryParams.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlParser.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java
Outdated
Show resolved
Hide resolved
…eld (#184361) ## Summary Based on elastic/elasticsearch#108421 Closes #180805 It allows the users to add an `?earliest` and `?latest` variable in the ES|QL editor. When we are detecting this variable, we are also sending the values to ES. - Earliest is the from value of the date picker - Latest is the to value of the date picker  Usage in bucket  This enables 2 very important features: - I can use the values of the time picker in the bucket function - I can use the time picker for indices without `@timestamp` field ### For reviewers - Although it seems as a big PR, the majority of the changes happen due to the signature change of the `getESQLAdHocDataview` - The ML changes are mostly because the ML code has a lot of repetition. I think the code needs to be refactored to have a central point (preferably the `getESQLResults` from the esql-utils. I will create an issue for the ML team. - I am not proposing this in bucket autocomplete because it doesnt work great in general for the date histogram case. We are working on autocomplete improvements so I am expecting this to be part of a follow up PR. - I want to talk to the docs team to add it in the docs. ### Follow ups - Change the histogram to use the bucket instead of the date_trunc (needs investigation first) - Speak with the docs team about adding an example on our official docs ### Flaky test runner https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6521 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Julia Rechkunova <julia.rechkunova@gmail.com>
Resolve #107029
Unnamed parameters are already supported in EsqlQueryRequest. e.g.
This PR is to support named and positional parameters in EsqlQueryRequest, e.g.
Named parameter:
Positional parameter
And also drop the support to explicit type: