Skip to content

Commit d4c7df2

Browse files
authored
ESQL: Add UNSUPPORTED type in unit tests (#119639) (#119687)
Small addition to tests, aligning their types better with production code.
1 parent 0da2fab commit d4c7df2

File tree

2 files changed

+49
-37
lines changed

2 files changed

+49
-37
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.core.Booleans;
2525
import org.elasticsearch.core.Releasable;
2626
import org.elasticsearch.core.Releasables;
27+
import org.elasticsearch.core.Strings;
2728
import org.elasticsearch.core.Tuple;
2829
import org.elasticsearch.logging.Logger;
2930
import org.elasticsearch.test.VersionUtils;
@@ -478,7 +479,15 @@ public enum Type {
478479
GEO_POINT(x -> x == null ? null : GEO.wktToWkb(x), BytesRef.class),
479480
CARTESIAN_POINT(x -> x == null ? null : CARTESIAN.wktToWkb(x), BytesRef.class),
480481
GEO_SHAPE(x -> x == null ? null : GEO.wktToWkb(x), BytesRef.class),
481-
CARTESIAN_SHAPE(x -> x == null ? null : CARTESIAN.wktToWkb(x), BytesRef.class);
482+
CARTESIAN_SHAPE(x -> x == null ? null : CARTESIAN.wktToWkb(x), BytesRef.class),
483+
UNSUPPORTED(Type::convertUnsupported, Void.class);
484+
485+
private static Void convertUnsupported(String s) {
486+
if (s != null) {
487+
throw new IllegalArgumentException(Strings.format("Unsupported type should always be null, was '%s'", s));
488+
}
489+
return null;
490+
}
482491

483492
private static final Map<String, Type> LOOKUP = new HashMap<>();
484493

@@ -536,6 +545,9 @@ public static Type asType(String name) {
536545
}
537546

538547
public static Type asType(ElementType elementType, Type actualType) {
548+
if (actualType == Type.UNSUPPORTED) {
549+
return UNSUPPORTED;
550+
}
539551
return switch (elementType) {
540552
case INT -> INTEGER;
541553
case LONG -> LONG;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/union_types.csv-spec

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ FROM sample_data, sample_data_str
263263
| LIMIT 1
264264
;
265265

266-
@timestamp:date | client_ip:null | event_duration:long | message:keyword
267-
2023-10-23T13:33:34.937Z | null | 1232382 | Disconnected
266+
@timestamp:date | client_ip:unsupported | event_duration:long | message:keyword
267+
2023-10-23T13:33:34.937Z | null | 1232382 | Disconnected
268268
;
269269

270270
multiIndexSortIpStringEval
@@ -278,8 +278,8 @@ FROM sample_data, sample_data_str
278278
| LIMIT 1
279279
;
280280

281-
@timestamp:date | client_ip:null | event_duration:long | message:keyword | client_ip_as_ip:ip
282-
2023-10-23T13:33:34.937Z | null | 1232382 | Disconnected | 172.21.0.5
281+
@timestamp:date | client_ip:unsupported | event_duration:long | message:keyword | client_ip_as_ip:ip
282+
2023-10-23T13:33:34.937Z | null | 1232382 | Disconnected | 172.21.0.5
283283
;
284284

285285
multiIndexIpStringStats
@@ -1270,11 +1270,11 @@ FROM sample_data* METADATA _index
12701270
| SORT _index ASC, ts DESC
12711271
;
12721272

1273-
@timestamp:null | client_ip:null | event_duration:long | message:keyword | _index:keyword | ts:date | ts_str:keyword | ts_l:long | ip:ip | ip_str:k
1274-
null | null | 8268153 | Connection error | sample_data | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015Z | 1698069175015 | 172.21.3.15 | 172.21.3.15
1275-
null | null | 8268153 | Connection error | sample_data_str | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015Z | 1698069175015 | 172.21.3.15 | 172.21.3.15
1276-
null | null | 8268153 | Connection error | sample_data_ts_long | 2023-10-23T13:52:55.015Z | 1698069175015 | 1698069175015 | 172.21.3.15 | 172.21.3.15
1277-
null | null | 8268153 | Connection error | sample_data_ts_nanos | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015123456Z | 1698069175015123456 | 172.21.3.15 | 172.21.3.15
1273+
@timestamp:unsupported | client_ip:unsupported | event_duration:long | message:keyword | _index:keyword | ts:date | ts_str:keyword | ts_l:long | ip:ip | ip_str:k
1274+
null | null | 8268153 | Connection error | sample_data | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015Z | 1698069175015 | 172.21.3.15 | 172.21.3.15
1275+
null | null | 8268153 | Connection error | sample_data_str | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015Z | 1698069175015 | 172.21.3.15 | 172.21.3.15
1276+
null | null | 8268153 | Connection error | sample_data_ts_long | 2023-10-23T13:52:55.015Z | 1698069175015 | 1698069175015 | 172.21.3.15 | 172.21.3.15
1277+
null | null | 8268153 | Connection error | sample_data_ts_nanos | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015123456Z | 1698069175015123456 | 172.21.3.15 | 172.21.3.15
12781278
;
12791279

12801280
multiIndexMultiColumnTypesRenameAndKeep
@@ -1381,8 +1381,8 @@ FROM sample_data, sample_data_ts_long
13811381
| LIMIT 1
13821382
;
13831383

1384-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword
1385-
null | 172.21.0.5 | 1232382 | Disconnected
1384+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword
1385+
null | 172.21.0.5 | 1232382 | Disconnected
13861386
;
13871387

13881388
multiIndexIndirectUseOfUnionTypesInEval
@@ -1393,8 +1393,8 @@ FROM sample_data, sample_data_ts_long
13931393
| LIMIT 1
13941394
;
13951395

1396-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | foo:boolean
1397-
null | 172.21.0.5 | 1232382 | Disconnected | true
1396+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | foo:boolean
1397+
null | 172.21.0.5 | 1232382 | Disconnected | true
13981398
;
13991399

14001400
multiIndexIndirectUseOfUnionTypesInRename
@@ -1406,8 +1406,8 @@ FROM sample_data, sample_data_ts_long
14061406
| LIMIT 1
14071407
;
14081408

1409-
@timestamp:null | client_ip:ip | event_duration:long | event_message:keyword
1410-
null | 172.21.0.5 | 1232382 | Disconnected
1409+
@timestamp:unsupported | client_ip:ip | event_duration:long | event_message:keyword
1410+
null | 172.21.0.5 | 1232382 | Disconnected
14111411
;
14121412

14131413
multiIndexIndirectUseOfUnionTypesInKeep
@@ -1431,8 +1431,8 @@ FROM sample_data, sample_data_ts_long
14311431
| LIMIT 1
14321432
;
14331433

1434-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword
1435-
null | 172.21.0.5 | 1232382 | Disconnected
1434+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword
1435+
null | 172.21.0.5 | 1232382 | Disconnected
14361436
;
14371437

14381438
multiIndexIndirectUseOfUnionTypesInWildcardKeep2
@@ -1444,8 +1444,8 @@ FROM sample_data, sample_data_ts_long
14441444
| LIMIT 1
14451445
;
14461446

1447-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword
1448-
null | 172.21.0.5 | 1232382 | Disconnected
1447+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword
1448+
null | 172.21.0.5 | 1232382 | Disconnected
14491449
;
14501450

14511451

@@ -1456,7 +1456,7 @@ FROM sample_data, sample_data_ts_long
14561456
| LIMIT 1
14571457
;
14581458

1459-
@timestamp:null
1459+
@timestamp:unsupported
14601460
null
14611461
;
14621462

@@ -1491,9 +1491,9 @@ FROM sample_data, sample_data_ts_long
14911491
| WHERE message == "Disconnected"
14921492
;
14931493

1494-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword
1495-
null | 172.21.0.5 | 1232382 | Disconnected
1496-
null | 172.21.0.5 | 1232382 | Disconnected
1494+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword
1495+
null | 172.21.0.5 | 1232382 | Disconnected
1496+
null | 172.21.0.5 | 1232382 | Disconnected
14971497
;
14981498

14991499
multiIndexIndirectUseOfUnionTypesInDissect
@@ -1504,8 +1504,8 @@ FROM sample_data, sample_data_ts_long
15041504
| LIMIT 1
15051505
;
15061506

1507-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1508-
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
1507+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1508+
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
15091509
;
15101510

15111511
multiIndexIndirectUseOfUnionTypesInGrok
@@ -1516,8 +1516,8 @@ FROM sample_data, sample_data_ts_long
15161516
| LIMIT 1
15171517
;
15181518

1519-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1520-
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
1519+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1520+
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
15211521
;
15221522

15231523
multiIndexIndirectUseOfUnionTypesInEnrich
@@ -1530,8 +1530,8 @@ FROM sample_data, sample_data_ts_long
15301530
| LIMIT 1
15311531
;
15321532

1533-
@timestamp:null | event_duration:long | message:keyword | client_ip:keyword | env:keyword
1534-
null | 1232382 | Disconnected | 172.21.0.5 | Development
1533+
@timestamp:unsupported | event_duration:long | message:keyword | client_ip:keyword | env:keyword
1534+
null | 1232382 | Disconnected | 172.21.0.5 | Development
15351535
;
15361536

15371537
multiIndexIndirectUseOfUnionTypesInStats
@@ -1557,8 +1557,8 @@ FROM sample_data, sample_data_ts_long
15571557
| LIMIT 1
15581558
;
15591559

1560-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | foo:long
1561-
null | 172.21.0.5 | 1232382 | Disconnected | 8268153
1560+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | foo:long
1561+
null | 172.21.0.5 | 1232382 | Disconnected | 8268153
15621562
;
15631563

15641564
multiIndexIndirectUseOfUnionTypesInLookup-Ignore
@@ -1571,8 +1571,8 @@ FROM sample_data, sample_data_ts_long
15711571
| LOOKUP_🐔 int_number_names ON int
15721572
;
15731573

1574-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | int:integer | name:keyword
1575-
null | 172.21.0.5 | 1232382 | Disconnected | 2 | two
1574+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | int:integer | name:keyword
1575+
null | 172.21.0.5 | 1232382 | Disconnected | 2 | two
15761576
;
15771577

15781578
multiIndexIndirectUseOfUnionTypesInMvExpand
@@ -1584,9 +1584,9 @@ FROM sample_data, sample_data_ts_long
15841584
| MV_EXPAND foo
15851585
;
15861586

1587-
@timestamp:null | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1588-
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
1589-
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
1587+
@timestamp:unsupported | client_ip:ip | event_duration:long | message:keyword | foo:keyword
1588+
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
1589+
null | 172.21.0.5 | 1232382 | Disconnected | Disconnected
15901590
;
15911591

15921592
shortIntegerWidening

0 commit comments

Comments
 (0)