Skip to content

Commit e245c17

Browse files
authored
ESQL: Add one more test of FTF with LOOKUP JOIN (#129781)
Add one more test of FTF with LOOKUP JOIN
1 parent 7b5e92f commit e245c17

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public class CsvTestsDataLoader {
8787
private static final TestDataset SAMPLE_DATA_TS_NANOS = SAMPLE_DATA.withIndex("sample_data_ts_nanos")
8888
.withData("sample_data_ts_nanos.csv")
8989
.withTypeMapping(Map.of("@timestamp", "date_nanos"));
90-
private static final TestDataset LOOKUP_SAMPLE_DATA_TS_NANOS = SAMPLE_DATA_TS_NANOS.withIndex("lookup_sample_data_ts_nanos")
90+
// the double underscore is meant to not match `sample_data*`, but do match `sample_*`
91+
private static final TestDataset SAMPLE_DATA_TS_NANOS_LOOKUP = SAMPLE_DATA_TS_NANOS.withIndex("sample__data_ts_nanos_lookup")
9192
.withSetting("lookup-settings.json");
9293
private static final TestDataset MISSING_IP_SAMPLE_DATA = new TestDataset("missing_ip_sample_data");
9394
private static final TestDataset SAMPLE_DATA_PARTIAL_MAPPING = new TestDataset("partial_mapping_sample_data");
@@ -172,7 +173,7 @@ public class CsvTestsDataLoader {
172173
Map.entry(SAMPLE_DATA_STR.indexName, SAMPLE_DATA_STR),
173174
Map.entry(SAMPLE_DATA_TS_LONG.indexName, SAMPLE_DATA_TS_LONG),
174175
Map.entry(SAMPLE_DATA_TS_NANOS.indexName, SAMPLE_DATA_TS_NANOS),
175-
Map.entry(LOOKUP_SAMPLE_DATA_TS_NANOS.indexName, LOOKUP_SAMPLE_DATA_TS_NANOS),
176+
Map.entry(SAMPLE_DATA_TS_NANOS_LOOKUP.indexName, SAMPLE_DATA_TS_NANOS_LOOKUP),
176177
Map.entry(MISSING_IP_SAMPLE_DATA.indexName, MISSING_IP_SAMPLE_DATA),
177178
Map.entry(CLIENT_IPS.indexName, CLIENT_IPS),
178179
Map.entry(CLIENT_IPS_LOOKUP.indexName, CLIENT_IPS_LOOKUP),

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ language_code:integer | language_name:keyword
120120
4 | German
121121
;
122122

123+
selfJoinWithOffset
124+
required_capability: join_lookup_v12
125+
126+
FROM languages_lookup
127+
| EVAL language_code = language_code + 2
128+
| LOOKUP JOIN languages_lookup ON language_code
129+
| SORT language_code
130+
;
131+
132+
language_code:integer | language_name:keyword
133+
3 |Spanish
134+
4 |German
135+
5 |null
136+
6 |null
137+
;
138+
123139
nonUniqueLeftKeyOnTheDataNode
124140
required_capability: join_lookup_v12
125141

@@ -4708,7 +4724,7 @@ required_capability: join_lookup_v12
47084724
required_capability: date_nanos_lookup_join
47094725

47104726
FROM sample_data_ts_nanos
4711-
| LOOKUP JOIN lookup_sample_data_ts_nanos ON @timestamp
4727+
| LOOKUP JOIN sample__data_ts_nanos_lookup ON @timestamp
47124728
| KEEP @timestamp, client_ip, event_duration, message
47134729
| SORT @timestamp DESC
47144730
;

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,31 @@ host:keyword | semantic_text_field:text | language_name:keyword | language_code:
752752
"host1" | live long and prosper | English | 1
753753
;
754754

755+
testFTFWithLookupJoin
756+
required_capability: match_operator_colon
757+
required_capability: match_phrase_function
758+
required_capability: kql_function
759+
required_capability: qstr_function
760+
required_capability: join_lookup_v12
761+
762+
FROM sample_*,-sample__data_*
763+
| WHERE message : "Connected to 10.1.0.1"
764+
| WHERE MATCH_PHRASE(message, "Connected to 10.1.0.1")
765+
| WHERE KQL("message : Connected*")
766+
| WHERE QSTR("message : *")
767+
| EVAL @timestamp_millis = TO_DATETIME(@timestamp)
768+
| EVAL client_ip = TO_IP(client_ip)
769+
| LOOKUP JOIN sample__data_ts_nanos_lookup ON client_ip
770+
| STATS BY @timestamp_millis, client_ip, @timestamp, event_duration, message
771+
| SORT event_duration
772+
;
773+
774+
@timestamp_millis:date |client_ip:ip |@timestamp:date_nanos |event_duration:long |message:keyword
775+
2023-10-23T13:55:01.543Z|172.21.3.15 |2023-10-23T13:51:54.732123456Z|725448 |Connection error
776+
2023-10-23T13:55:01.543Z|172.21.3.15 |2023-10-23T13:55:01.543123456Z|1756467 |Connected to 10.1.0.1
777+
2023-10-23T13:55:01.543Z|172.21.3.15 |2023-10-23T13:53:55.832123456Z|5033755 |Connection error
778+
2023-10-23T13:55:01.543Z|172.21.3.15 |2023-10-23T13:52:55.015123456Z|8268153 |Connection error
779+
;
755780

756781
testMatchInStatsNonPushable
757782
required_capability: match_operator_colon

0 commit comments

Comments
 (0)