-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Change queries ID to be the same as the async #127472
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
Changes from 11 commits
0383960
a463ba5
0948424
25fee06
9f2e297
ec7f125
79a9669
e3958c0
de60192
9011486
6dfa323
24b654e
6791493
b1eedc6
c6a717a
5a017be
62e421e
de56665
fcdb7a8
398ba4c
f46d1fa
45b4e8e
e61f293
bbd87ac
7adbc29
2abb63d
84dcd7c
46f7494
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 127472 | ||
| summary: Change queries ID to be the same as the async | ||
| area: ES|QL | ||
| type: feature | ||
| issues: | ||
| - 127187 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| "id" : 5326, | ||
| "type" : "transport", | ||
| "action" : "indices:data/read/esql", | ||
| "status" : "Ks5ApyqMTtWj5LrKigmCjQ", | ||
|
||
| "description" : "FROM test | STATS MAX(d) by a, b", <1> | ||
| "start_time" : "2023-07-31T15:46:32.328Z", | ||
| "start_time_in_millis" : 1690818392328, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import org.elasticsearch.action.ActionRequestValidationException; | ||
| import org.elasticsearch.action.CompositeIndicesRequest; | ||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.UUIDs; | ||
| import org.elasticsearch.common.breaker.NoopCircuitBreaker; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.settings.Settings; | ||
|
|
@@ -22,6 +23,7 @@ | |
| import org.elasticsearch.tasks.TaskId; | ||
| import org.elasticsearch.xpack.esql.Column; | ||
| import org.elasticsearch.xpack.esql.parser.QueryParams; | ||
| import org.elasticsearch.xpack.esql.plugin.EsqlDocIdStatus; | ||
| import org.elasticsearch.xpack.esql.plugin.QueryPragmas; | ||
|
|
||
| import java.io.IOException; | ||
|
|
@@ -243,8 +245,14 @@ public EsqlQueryRequest allowPartialResults(boolean allowPartialResults) { | |
|
|
||
| @Override | ||
| public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) { | ||
| EsqlDocIdStatus status = new EsqlDocIdStatus(UUIDs.randomBase64UUID()); | ||
| // Pass the query as the description | ||
| return new CancellableTask(id, type, action, query, parentTaskId, headers); | ||
| return new CancellableTask(id, type, action, query, parentTaskId, headers) { | ||
| @Override | ||
| public Status getStatus() { | ||
| return status; | ||
| } | ||
|
||
| }; | ||
| } | ||
|
|
||
| // Setter for tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.esql.plugin; | ||
|
|
||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.tasks.Task; | ||
| import org.elasticsearch.tasks.TaskId; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
| import org.elasticsearch.xpack.core.async.AsyncExecutionId; | ||
| import org.elasticsearch.xpack.esql.action.EsqlQueryAction; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Keeps track of the doc ID, which is itself used for {@link AsyncExecutionId}. | ||
| * | ||
| * The reason this contains just the doc ID and not the entire {@link AsyncExecutionId} is that during the creation of | ||
| * {@link EsqlQueryAction}, we don't have access to the node ID yet, thus we can't create a {@link TaskId} yet. | ||
| */ | ||
| public record EsqlDocIdStatus(String id) implements Task.Status { | ||
| public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry( | ||
| Task.Status.class, | ||
| "EsqlDocIdStatus", | ||
| EsqlDocIdStatus::new | ||
| ); | ||
|
|
||
| @Override | ||
| public String getWriteableName() { | ||
| return ENTRY.name; | ||
| } | ||
|
|
||
| private EsqlDocIdStatus(StreamInput stream) throws IOException { | ||
| this(stream.readString()); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(id); | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| return builder.rawValue(Strings.format("\"%s\"", id)); | ||
| } | ||
| } |
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.
Worth adding an
AbstractWireTestCasesubclass for this then.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.
Done.