From 7638cd30b4a2e0a547538bd91d2d802101915a82 Mon Sep 17 00:00:00 2001 From: "ievgen.degtiarenko" Date: Wed, 18 Dec 2024 15:03:37 +0100 Subject: [PATCH] Ensure nested field could be used in lookup joins --- .../xpack/esql/CsvTestsDataLoader.java | 2 ++ .../resources/languages_nested_fields.csv | 5 +++++ .../src/main/resources/lookup-join.csv-spec | 22 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 x-pack/plugin/esql/qa/testFixtures/src/main/resources/languages_nested_fields.csv diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java index 8e81d14b4dfd7..1648b965c6bab 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java @@ -64,6 +64,8 @@ public class CsvTestsDataLoader { .withSetting("languages_lookup-settings.json"); private static final TestsDataset LANGUAGES_LOOKUP_NON_UNIQUE_KEY = LANGUAGES_LOOKUP.withIndex("languages_lookup_non_unique_key") .withData("languages_non_unique_key.csv"); + private static final TestsDataset LANGUAGES_NESTED_FIELDS = LANGUAGES_LOOKUP.withIndex("languages_nested_fields") + .withData("languages_nested_fields.csv"); private static final TestsDataset ALERTS = new TestsDataset("alerts"); private static final TestsDataset UL_LOGS = new TestsDataset("ul_logs"); private static final TestsDataset SAMPLE_DATA = new TestsDataset("sample_data"); diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/languages_nested_fields.csv b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/languages_nested_fields.csv new file mode 100644 index 0000000000000..f26114245a6d3 --- /dev/null +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/languages_nested_fields.csv @@ -0,0 +1,5 @@ +_id:integer,language.id:integer,language.name:keyword,language.code:keyword +1,1,English,EN +2,2,French,FR +3,3,Spanish,ES +4,4,German,DE diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec index 7d4f89ed920a9..8b69d97a43bcd 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec @@ -416,6 +416,28 @@ language_code:integer | language_name:keyword | country:keyword 8 | Mv-Lang2 | Mv-Land2 ; +########################################################################### +# nested filed join behavior with languages_nested_fields index +########################################################################### + +joinOnNestedField +required_capability: join_lookup_v8 + +FROM employees +| WHERE 10000 < emp_no AND emp_no < 10005 +| EVAL language.id = emp_no % 10 +| LOOKUP JOIN languages_nested_fields ON language.id +| SORT emp_no +| KEEP emp_no, language.id, language.name +; + +emp_no:integer | language.id:integer | language.name:keyword +10001 | 1 | English +10002 | 2 | French +10003 | 3 | Spanish +10004 | 4 | German +; + ############################################### # Tests with clientips_lookup index ###############################################