Skip to content

Commit

Permalink
ESQL: Entirely drop version field (#109169)
Browse files Browse the repository at this point in the history
This field is no longer supported.
  • Loading branch information
nik9000 authored May 29, 2024
1 parent 66e0b00 commit 652066d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ final class RequestXContent {
PARAM_PARSER.declareString(constructorArg(), TYPE);
}

static final ParseField ESQL_VERSION_FIELD = new ParseField("version");
static final ParseField QUERY_FIELD = new ParseField("query");
private static final ParseField COLUMNAR_FIELD = new ParseField("columnar");
private static final ParseField FILTER_FIELD = new ParseField("filter");
Expand All @@ -73,7 +72,6 @@ static EsqlQueryRequest parseAsync(XContentParser parser) {
}

private static void objectParserCommon(ObjectParser<EsqlQueryRequest, ?> parser) {
parser.declareString((str, consumer) -> {}, ESQL_VERSION_FIELD);
parser.declareString(EsqlQueryRequest::query, QUERY_FIELD);
parser.declareBoolean(EsqlQueryRequest::columnar, COLUMNAR_FIELD);
parser.declareObject(EsqlQueryRequest::filter, (p, c) -> AbstractQueryBuilder.parseTopLevelQuery(p), FILTER_FIELD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,41 +149,10 @@ public void testRejectUnknownFields() {
}""", "unknown field [asdf]");
}

public void testAnyVersionIsValid() throws IOException {
String validVersionString = randomAlphaOfLength(5);

String json = String.format(Locale.ROOT, """
{
"version": "%s",
"query": "ROW x = 1"
}
""", validVersionString);

EsqlQueryRequest request = parseEsqlQueryRequest(json, randomBoolean());
assertNull(request.validate());

request = parseEsqlQueryRequestAsync(json);
assertNull(request.validate());
}

public void testMissingVersionIsValid() throws IOException {
String missingVersion = randomBoolean() ? "" : ", \"version\": \"\"";
String json = String.format(Locale.ROOT, """
{
"columnar": true,
"query": "row x = 1"
%s
}""", missingVersion);

EsqlQueryRequest request = parseEsqlQueryRequest(json, randomBoolean());
assertNull(request.validate());
}

public void testMissingQueryIsNotValid() throws IOException {
String json = """
{
"columnar": true,
"version": "snapshot"
"columnar": true
}""";
EsqlQueryRequest request = parseEsqlQueryRequest(json, randomBoolean());
assertNotNull(request.validate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,15 @@ setup:
- match: {values.0: ["1",2.0,null,true,123,123]}
- match: {values.1: ["1",2.0,null,true,123,123]}
- match: {values.2: ["1",2.0,null,true,123,123]}

---
version is not allowed:
- requires:
cluster_features: ["gte_v8.14.0"]
reason: version allowed in 8.13.latest
- do:
catch: /unknown field \[version\]/
esql.query:
body:
query: 'from test'
version: cat

0 comments on commit 652066d

Please sign in to comment.