-
Notifications
You must be signed in to change notification settings - Fork 25.4k
ESQL: Enable async get to support formatting #111104
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
ESQL: Enable async get to support formatting #111104
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Thanks for your interest, @kanoshiou. We'll want to make sure that all operations are possible and work in Besides that any change would require tests. For |
@bpintea I agree with this. I will work on making sure that when the request is in However, after reviewing the code for Currently, |
…support format and delimiter in params
This reverts commit e81487a.
Hi @bpintea , I believe I have completed the code. Could you please review it when you have some time? I've updated the listener for You can now set the |
…rns-as-headers-in-text-mode
@kanoshiou sorry for getting back late. |
...ugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
Outdated
Show resolved
Hide resolved
...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/action/EsqlResponseListener.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlMediaTypeParser.java
Outdated
Show resolved
Hide resolved
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.
Just some minor notes, looking good otherwise.
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlMediaTypeParser.java
Outdated
Show resolved
Hide resolved
...ugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
Outdated
Show resolved
Hide resolved
@bpintea Thank you very much! I have updated the branch based on your comments. |
@elasticsearchmachine test this please |
Hi @bpintea, I would like to know how I should resolve these test failures, as I can't see the details. |
Default to JSON in this case.
…eaders-in-text-mode
I'm not sure how/if you can access the test results. But most of them will be revealed if you run locally The tests failed because of missing media type indication. We're a bit inconsistent here, but ES allows a (search) GET with no media type indication whatsoever, so I need to revise my previous comment about supporting a default -- I've pushed a fix for that. However, I'd kindly ask you to add tests for this (i.e. an async GET with no media indication) then too, both |
@elasticsearchmachine test this please |
@bpintea Thank you for letting me know.
Sure thing! I will implement the tests ASAP. |
@bpintea I've added the tests. Please review. |
@elasticsearchmachine test this please |
@elasticsearchmachine test this please |
@elasticsearchmachine test this please |
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.
Looks good, thanks @kanoshiou.
|
||
} | ||
|
||
static Request prepareRequestWithOptions(RequestObjectBuilder requestObject, Mode mode) throws IOException { |
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.
👍
var json = entityToMap(entity, requestObject.contentType()); | ||
checkKeepOnCompletion(requestObject, json, true); | ||
String id = (String) json.get("id"); | ||
// results won't be returned since keepOnCompletion is true |
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.
Nit: if they're not returned, it's because the waitForCompletion()
is provided a very small interval (see addAsyncParameters()
), so ES won't have the time to query and respond with results in time.
// results won't be returned since keepOnCompletion is true | ||
assertThat(id, is(not(emptyOrNullString()))); | ||
|
||
// issue an "async get" request with no Content-Type |
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.
👍
💚 Backport successful
|
I've updated the listener for GET /_query/async/{id} to EsqlResponseListener, so it now accepts parameters (delimiter, drop_null_columns and format) like the POST /_query API. Additionally, I have added tests to verify the correctness of the code. You can now set the format in the request parameters to specify the return style. Closes elastic#110926
@bpintea, Thank you so much for taking the time to review my code. I truly appreciate your patience and attention to detail. This has been an unforgettable experience, and I have learned a lot.😊 |
I've updated the listener for GET /_query/async/{id} to EsqlResponseListener, so it now accepts parameters (delimiter, drop_null_columns and format) like the POST /_query API. Additionally, I have added tests to verify the correctness of the code. You can now set the format in the request parameters to specify the return style. Closes #110926 Co-authored-by: kanoshiou <[email protected]>
An async request in text mode (
POST _query/async?format=txt
) previously returned an empty body without providing an async ID. I have now implemented the second approach mentioned in the issue #110926. Now, the async parameters (Async-ID
&Async-running
) are returned as headers.However, I discovered an issue: when using the async ID from a text mode request to query
/_query/async/{id}
, the returned data format is still JSON. This might be a bug, and perhaps the response should be in plain text format, matching the initial request.Closes #110926