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
bpintea
left a comment
There was a problem hiding this comment.
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 |
bpintea
left a comment
There was a problem hiding this comment.
Looks good, thanks @kanoshiou.
|
|
||
| } | ||
|
|
||
| static Request prepareRequestWithOptions(RequestObjectBuilder requestObject, Mode mode) throws IOException { |
| 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.
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 |
💚 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 <73424326+kanoshiou@users.noreply.github.com>
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