Skip to content

Commit 3dc4176

Browse files
Revert "Add support for VERSION field type in SQL and EQL (#85502)"
This reverts commit 79b0078.
1 parent 79b0078 commit 3dc4176

File tree

51 files changed

+40
-1018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+40
-1018
lines changed

docs/changelog/85502.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/reference/sql/language/data-types.asciidoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ s|SQL precision
2828
| <<binary, `binary`>> | binary | VARBINARY | 2,147,483,647
2929
| <<date, `date`>> | datetime | TIMESTAMP | 29
3030
| <<ip, `ip`>> | ip | VARCHAR | 39
31-
| <<version, `version`>> | version | VARCHAR | 32,766
3231

3332
4+h| Complex types
3433

x-pack/plugin/eql/qa/common/src/main/resources/data/extra.data

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
"transID": 2,
113113
"process.entity_id": 512,
114114
"process.pid": 123,
115-
"version": "1.5.0",
116115
"sequence": 18
117116
},
118117
{
@@ -121,7 +120,6 @@
121120
"transID": 0,
122121
"process.entity_id": 512,
123122
"process.pid": 123,
124-
"version": "1.5.0",
125123
"sequence": 19
126124
},
127125
{
@@ -130,7 +128,6 @@
130128
"transID": 0,
131129
"process.entity_id": 512,
132130
"process.pid": 123,
133-
"version": "1.2.4",
134131
"sequence": 20
135132
},
136133
{
@@ -139,7 +136,6 @@
139136
"transID": 0,
140137
"process.entity_id": 512,
141138
"process.pid": 123,
142-
"version": "1.11.3",
143139
"sequence": 21
144140
},
145141
{
@@ -148,7 +144,6 @@
148144
"transID": 0,
149145
"process.entity_id": 512,
150146
"process.pid": 123,
151-
"version": "bad",
152147
"sequence": 22
153148
},
154149
{
@@ -157,7 +152,6 @@
157152
"transID": 0,
158153
"process.entity_id": 512,
159154
"process.pid": 123,
160-
"version": "1.2.4-SNAPSHOT",
161155
"sequence": 23
162156
}
163157
]

x-pack/plugin/eql/qa/common/src/main/resources/data/extra.mapping

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
"optional_field_default_null": {
2828
"type": "keyword",
2929
"null_value": "NULL"
30-
},
31-
"version": {
32-
"type": "version"
3330
}
3431
}
3532
}

x-pack/plugin/eql/qa/common/src/main/resources/test_extra.toml

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ expected_event_ids = []
7676
[[queries]]
7777
name = "sequenceOptionalFieldAsKeyAndFirstFilter"
7878
query = '''
79-
sequence by ?x
79+
sequence by ?x
8080
[OPTIONAL where ?x == null]
8181
[OPTIONAL where true]
8282
'''
@@ -137,7 +137,7 @@ expected_event_ids = [12,13,14,
137137
join_keys = ["null","123",
138138
"null","null",
139139
"512","123"]
140-
140+
141141
[[queries]]
142142
name = "sequenceOneKeyOptional_1"
143143
query = '''
@@ -159,7 +159,7 @@ expected_event_ids = [12,13,14,
159159
18,19,20]
160160
join_keys = ["null","123",
161161
"512","123"]
162-
162+
163163
[[queries]]
164164
name = "sequenceNoOptionalKeys"
165165
query = '''
@@ -195,7 +195,7 @@ expected_event_ids = [12,13,14,
195195
join_keys = ["null","123",
196196
"null","null",
197197
"512","123"]
198-
198+
199199
[[queries]]
200200
name = "sequenceWithOptionalFieldsAndUntil_2"
201201
query = '''
@@ -209,65 +209,3 @@ expected_event_ids = [12,13,14,
209209
join_keys = ["null","123",
210210
"null","null"]
211211

212-
[[queries]]
213-
name = "sequenceWithVersionCheck"
214-
query = '''
215-
sequence by transID
216-
[ file where version == "1.2.4" ]
217-
[ file where version == "1.11.3" ]
218-
'''
219-
expected_event_ids = [20, 21]
220-
join_keys = ["0"]
221-
222-
[[queries]]
223-
name = "sequenceWithVersionRangeCheck"
224-
query = '''
225-
sequence by transID
226-
[ file where version == "1.2.4" ]
227-
[ file where version > "1.5.0" ]
228-
'''
229-
expected_event_ids = [20, 21]
230-
join_keys = ["0"]
231-
232-
[[queries]]
233-
name = "sequenceWithVersionRangeCheck2"
234-
query = '''
235-
sequence by transID
236-
[ file where version == "1.2.4" ]
237-
[ file where version < "1.5.0" ]
238-
'''
239-
expected_event_ids = [20, 23]
240-
join_keys = ["0"]
241-
242-
243-
[[queries]]
244-
name = "sequenceWithInvalidVersion"
245-
query = '''
246-
sequence by transID
247-
[ file where version == "1.2.4" ]
248-
[ file where version == "bad" ]
249-
'''
250-
expected_event_ids = [20, 22]
251-
join_keys = ["0"]
252-
253-
254-
[[queries]]
255-
name = "sequenceWithVersionConcat"
256-
query = '''
257-
sequence by transID
258-
[ file where CONCAT(version, "") == "1.2.4" ]
259-
[ file where version == "bad" ]
260-
'''
261-
expected_event_ids = [20, 22]
262-
join_keys = ["0"]
263-
264-
265-
[[queries]]
266-
name = "sequenceWithVersionJoinKey"
267-
query = '''
268-
sequence by version
269-
[ process where true ]
270-
[ file where true ]
271-
'''
272-
expected_event_ids = [18, 19]
273-
join_keys = ["1.5.0"]

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/execution/search/SourceGenerator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.search.fetch.subphase.FieldAndFormat;
1212
import org.elasticsearch.search.sort.FieldSortBuilder;
1313
import org.elasticsearch.search.sort.NestedSortBuilder;
14+
import org.elasticsearch.search.sort.ScriptSortBuilder.ScriptSortType;
1415
import org.elasticsearch.search.sort.SortBuilder;
1516
import org.elasticsearch.xpack.eql.querydsl.container.QueryContainer;
1617
import org.elasticsearch.xpack.ql.execution.search.QlSourceBuilder;
@@ -132,7 +133,10 @@ private static void sorting(QueryContainer container, SearchSourceBuilder source
132133
}
133134
}
134135
} else if (sortable instanceof ScriptSort ss) {
135-
sortBuilder = scriptSort(ss.script().toPainless(), ss.script().outputType().scriptSortType());
136+
sortBuilder = scriptSort(
137+
ss.script().toPainless(),
138+
ss.script().outputType().isNumeric() ? ScriptSortType.NUMBER : ScriptSortType.STRING
139+
);
136140
}
137141

138142
if (sortBuilder != null) {

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPainlessExtension.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.painless.spi.WhitelistLoader;
1212
import org.elasticsearch.script.AggregationScript;
1313
import org.elasticsearch.script.BucketAggregationSelectorScript;
14-
import org.elasticsearch.script.BytesRefSortScript;
1514
import org.elasticsearch.script.FieldScript;
1615
import org.elasticsearch.script.FilterScript;
1716
import org.elasticsearch.script.NumberSortScript;
@@ -37,7 +36,6 @@ public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
3736
whitelist.put(FieldScript.CONTEXT, list);
3837
whitelist.put(NumberSortScript.CONTEXT, list);
3938
whitelist.put(StringSortScript.CONTEXT, list);
40-
whitelist.put(BytesRefSortScript.CONTEXT, list);
4139
whitelist.put(BucketAggregationSelectorScript.CONTEXT, list);
4240
return whitelist;
4341
}

x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/analysis/VerifierTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public void testQueryCondition() {
9393
assertEquals("1:11: Condition expression needs to be boolean, found [TEXT]", error("any where hostname"));
9494
assertEquals("1:11: Condition expression needs to be boolean, found [KEYWORD]", error("any where constant_keyword"));
9595
assertEquals("1:11: Condition expression needs to be boolean, found [IP]", error("any where source_address"));
96-
assertEquals("1:11: Condition expression needs to be boolean, found [VERSION]", error("any where version"));
9796
}
9897

9998
public void testQueryStartsWithNumber() {
@@ -364,11 +363,6 @@ public void testIP() {
364363
accept(idxr, "foo where ip_addr == 0");
365364
}
366365

367-
public void testVersion() {
368-
final IndexResolution idxr = loadIndexResolution("mapping-version.json");
369-
accept(idxr, "foo where version_number == \"2.1.4\"");
370-
}
371-
372366
public void testJoin() {
373367
final IndexResolution idxr = loadIndexResolution("mapping-join.json");
374368
accept(idxr, "foo where serial_event_id == 0");

x-pack/plugin/eql/src/test/resources/mapping-default.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@
9090
},
9191
"bool" : {
9292
"type" : "boolean"
93-
},
94-
"version" : {
95-
"type" : "version"
9693
}
9794
}
9895
}

x-pack/plugin/eql/src/test/resources/mapping-version.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

x-pack/plugin/eql/src/test/resources/querytranslator_tests.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -901,17 +901,3 @@ process where pid > 100 and pid < 200
901901
// the "not" has an undefined location of where it should be used in the Painless script
902902
// disjunctionInsideFunctionWithNot
903903
// process where string(pid > 5 and pid != 10) == \"true\"
904-
905-
906-
versionFieldAutomaticConversion
907-
process where version > "2"
908-
;
909-
{"range":{"version":{"gt":"2"
910-
;
911-
912-
versionFieldCast
913-
process where CONCAT(version, constant_keyword) > "2"
914-
;
915-
{"script":{"source":"InternalEqlScriptUtils.multiValueDocValues(doc,params.v0,X0->InternalEqlScriptUtils.multiValueDocValues(doc,params.v1,X1->InternalQlScriptUtils.nullSafeFilter(InternalQlScriptUtils.gt(InternalEqlScriptUtils.concat([X0,X1]),params.v2))))"
916-
"params":{"v0":"version","v1":"constant_keyword","v2":"2"}}
917-
;

x-pack/plugin/ql/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ archivesBaseName = 'x-pack-ql'
1616

1717
dependencies {
1818
api "org.antlr:antlr4-runtime:${antlrVersion}"
19-
api project(path: xpackModule('mapper-version'))
2019
compileOnly project(path: xpackModule('core'))
2120
testApi(project(xpackModule('ql:test-fixtures'))) {
2221
exclude group: 'org.elasticsearch.plugin', module: 'ql'

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/operator/comparison/Comparisons.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
package org.elasticsearch.xpack.ql.expression.predicate.operator.comparison;
88

9-
import org.elasticsearch.xpack.versionfield.Version;
10-
119
import java.math.BigInteger;
1210
import java.util.Set;
1311

@@ -73,21 +71,13 @@ static Integer compare(Object l, Object r) {
7371
return null;
7472
}
7573
// typical number comparison
76-
if (l instanceof Number lN && r instanceof Number rN) {
77-
return compare(lN, rN);
78-
}
79-
80-
// automatic conversion for versions
81-
if (l instanceof Version lV && r instanceof String rStr) {
82-
return lV.compareTo(new Version(rStr));
83-
}
84-
if (l instanceof String lStr && r instanceof Version rV) {
85-
return new Version(lStr).compareTo(rV);
74+
if (l instanceof Number && r instanceof Number) {
75+
return compare((Number) l, (Number) r);
8676
}
8777

88-
if (l instanceof Comparable lC && r instanceof Comparable) {
78+
if (l instanceof Comparable && r instanceof Comparable) {
8979
try {
90-
return Integer.valueOf(lC.compareTo(r));
80+
return Integer.valueOf(((Comparable) l).compareTo(r));
9181
} catch (ClassCastException cce) {
9282
// when types are not compatible, cce is thrown
9383
// fall back to null

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/VersionCompatibilityChecks.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,18 @@
1212
import org.elasticsearch.xpack.ql.type.DataType;
1313

1414
import static org.elasticsearch.Version.V_8_2_0;
15-
import static org.elasticsearch.Version.V_8_4_0;
1615
import static org.elasticsearch.xpack.ql.type.DataTypes.UNSIGNED_LONG;
17-
import static org.elasticsearch.xpack.ql.type.DataTypes.VERSION;
1816

1917
public final class VersionCompatibilityChecks {
2018

2119
public static final Version INTRODUCING_UNSIGNED_LONG = V_8_2_0;
22-
public static final Version INTRODUCING_VERSION_FIELD_TYPE = V_8_4_0;
2320

2421
private VersionCompatibilityChecks() {}
2522

2623
public static boolean isTypeSupportedInVersion(DataType dataType, Version version) {
2724
if (dataType == UNSIGNED_LONG) {
2825
return supportsUnsignedLong(version);
2926
}
30-
if (dataType == VERSION) {
31-
return supportsVersionType(version);
32-
}
3327
return true;
3428
}
3529

@@ -40,20 +34,10 @@ public static boolean supportsUnsignedLong(Version version) {
4034
return INTRODUCING_UNSIGNED_LONG.compareTo(version) <= 0;
4135
}
4236

43-
/**
44-
* Does the provided {@code version} support the version type (PR#85502)?
45-
*/
46-
public static boolean supportsVersionType(Version version) {
47-
return INTRODUCING_VERSION_FIELD_TYPE.compareTo(version) <= 0;
48-
}
49-
5037
public static @Nullable Version versionIntroducingType(DataType dataType) {
5138
if (dataType == UNSIGNED_LONG) {
5239
return INTRODUCING_UNSIGNED_LONG;
5340
}
54-
if (dataType == VERSION) {
55-
return INTRODUCING_VERSION_FIELD_TYPE;
56-
}
5741

5842
return null;
5943
}

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/type/DataType.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
package org.elasticsearch.xpack.ql.type;
99

10-
import org.elasticsearch.search.sort.ScriptSortBuilder;
11-
1210
import java.util.Locale;
1311
import java.util.Objects;
1412

@@ -64,12 +62,6 @@ public String esType() {
6462
return esType;
6563
}
6664

67-
public ScriptSortBuilder.ScriptSortType scriptSortType() {
68-
return isNumeric() ? ScriptSortBuilder.ScriptSortType.NUMBER
69-
: this == DataTypes.VERSION ? ScriptSortBuilder.ScriptSortType.VERSION
70-
: ScriptSortBuilder.ScriptSortType.STRING;
71-
}
72-
7365
public boolean isInteger() {
7466
return isInteger;
7567
}

0 commit comments

Comments
 (0)