Skip to content

Commit

Permalink
Revert "Add EQ|QL version support with its default value (#791) (#792)"
Browse files Browse the repository at this point in the history
This reverts commit 8f4c36c.
  • Loading branch information
l-trotta committed May 27, 2024
1 parent f0c2440 commit 444ffd8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlAsyncClient;
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlClient;
import co.elastic.clients.elasticsearch.esql.EsqlVersion;
import co.elastic.clients.elasticsearch.esql.QueryRequest;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.transport.endpoints.BinaryResponse;
Expand All @@ -37,9 +36,9 @@ public class EsqlHelper {
//----- Synchronous

public static <T> T query(
ElasticsearchEsqlClient client, EsqlVersion version, EsqlAdapter<T> adapter, String query, Object... params
ElasticsearchEsqlClient client, EsqlAdapter<T> adapter, String query, Object... params
) throws IOException {
QueryRequest request = buildRequest(version, adapter, query, params);
QueryRequest request = buildRequest(adapter, query, params);
BinaryResponse response = client.query(request);
return adapter.deserialize(client, request, response);
}
Expand All @@ -53,9 +52,9 @@ public static <T> T query(ElasticsearchEsqlClient client, EsqlAdapter<T> adapter
//----- Asynchronous

public static <T> CompletableFuture<T> queryAsync(
ElasticsearchEsqlAsyncClient client, EsqlVersion version, EsqlAdapter<T> adapter, String query, Object... params
ElasticsearchEsqlAsyncClient client, EsqlAdapter<T> adapter, String query, Object... params
) {
return doQueryAsync(client, adapter, buildRequest(version, adapter, query, params));
return doQueryAsync(client, adapter, buildRequest(adapter, query, params));
}

public static <T> CompletableFuture<T> queryAsync(
Expand All @@ -80,19 +79,9 @@ private static <T> CompletableFuture<T> doQueryAsync(

//----- Utilities

private static QueryRequest buildRequest(EsqlVersion version, EsqlAdapter<?> adapter, String query, Object... params) {
if (version == null) {
version = EsqlVersion.getDefault();
}
if (version == null) {
throw new IllegalStateException(
"ES|QL default version not set. Either specify it explicitly or set a default value");
}
EsqlVersion v = version;

private static QueryRequest buildRequest(EsqlAdapter<?> adapter, String query, Object... params) {
return QueryRequest.of(esql -> esql
.format(adapter.format())
.version(v)
.columnar(adapter.columnar())
.query(query)
.params(asFieldValues(params))
Expand All @@ -110,7 +99,6 @@ private static QueryRequest buildRequest(EsqlAdapter<?> adapter, QueryRequest re
.locale(request.locale())
.params(request.params())
.query(request.query())
.version(request.version())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public synchronized ElasticsearchTestServer start() {
return this;
}

Version version = Version.VERSION.major() < 8 ? new Version(7,17,5,false) : new Version(8,14,0,false);
Version version = Version.VERSION.major() < 8 ? new Version(7,17,5,false) : new Version(8,12,0,false);

// Note we could use version.major() + "." + version.minor() + "-SNAPSHOT" but plugins won't install on a snapshot version
String esImage = "docker.elastic.co/elasticsearch/elasticsearch:" + version + "-SNAPSHOT";
String esImage = "docker.elastic.co/elasticsearch/elasticsearch:" + version;

DockerImageName image;
if (plugins.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void objectsTest() throws Exception {
{
EmpData emp = it.next();
assertEquals("10042", emp.empNo);
assertEquals(Arrays.asList("Architect", "Business Analyst", "Junior Developer", "Internship"), emp.jobPositions);
assertEquals(Arrays.asList("Architect", "Business Analyst", "Internship", "Junior Developer"), emp.jobPositions);

assertEquals("1993-03-21T00:00:00Z[UTC]",
DateTimeFormatter.ISO_DATE_TIME.format(emp.hireDate.toInstant().atZone(ZoneId.of("UTC")))
Expand Down Expand Up @@ -172,7 +172,7 @@ public void asyncObjects() throws Exception {
{
EmpData emp = it.next();
assertEquals("10042", emp.empNo);
assertEquals(Arrays.asList("Architect", "Business Analyst", "Junior Developer", "Internship"), emp.jobPositions);
assertEquals(Arrays.asList("Architect", "Business Analyst", "Internship", "Junior Developer"), emp.jobPositions);

assertEquals("1993-03-21T00:00:00Z[UTC]",
DateTimeFormatter.ISO_DATE_TIME.format(emp.hireDate.toInstant().atZone(ZoneId.of("UTC")))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public void i0254_suggesterTest() throws Exception {
}

@Test
@Disabled("Plugins cannot be installed on snapshot versions of ES")
public void i0249_variantKind() throws Exception {
try (ElasticsearchTestServer server = new ElasticsearchTestServer("analysis-icu").start()) {

Expand Down

0 comments on commit 444ffd8

Please sign in to comment.