From b081c1a13cd88e1f23b444f650a383308cd688f7 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Fri, 9 May 2025 15:22:33 +0200 Subject: [PATCH 1/2] Additional yaml test for missing join key on right side (#127906) There are some analyser tests for this, but I thought it useful to also have a yaml test for more coverage, since there was temporarily an issue #120189 with this, later fixed in #120617. --- .../test/esql/190_lookup_join.yml | 118 +++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml index f72cdd65b275c..40c6db728a2e1 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml @@ -1,12 +1,12 @@ --- setup: - requires: - test_runner_features: [capabilities, contains] + test_runner_features: [capabilities, contains, allowed_warnings] capabilities: - method: POST path: /_query parameters: [] - capabilities: [join_lookup_v12] + capabilities: [join_lookup_v12, join_lookup_skip_mv_warnings] reason: "uses LOOKUP JOIN" - do: indices.create: @@ -18,6 +18,16 @@ setup: type: long color: type: keyword + - do: + indices.create: + index: test-mv + body: + mappings: + properties: + key: + type: long + color: + type: keyword - do: indices.create: index: test-lookup-1 @@ -44,6 +54,32 @@ setup: type: long color: type: keyword + - do: + indices.create: + index: test-lookup-mv + body: + settings: + index: + mode: lookup + mappings: + properties: + key: + type: long + color: + type: keyword + - do: + indices.create: + index: test-lookup-no-key + body: + settings: + index: + mode: lookup + mappings: + properties: + no-key: + type: long + color: + type: keyword - do: indices.update_aliases: body: @@ -75,6 +111,37 @@ setup: - { "key": 1, "color": "cyan" } - { "index": { } } - { "key": 2, "color": "yellow" } + - do: + bulk: + index: "test-mv" + refresh: true + body: + - { "index": { } } + - { "key": 1, "color": "red" } + - { "index": { } } + - { "key": 2, "color": "blue" } + - { "index": { } } + - { "key": [0, 1, 2], "color": null } + - do: + bulk: + index: "test-lookup-mv" + refresh: true + body: + - { "index": { } } + - { "key": 1, "color": "cyan" } + - { "index": { } } + - { "key": 2, "color": "yellow" } + - { "index": { } } + - { "key": [0, 1, 2], "color": "green" } + - do: + bulk: + index: "test-lookup-no-key" + refresh: true + body: + - { "index": { } } + - { "no-key": 1, "color": "cyan" } + - { "index": { } } + - { "no-key": 2, "color": "yellow" } --- basic: @@ -200,3 +267,50 @@ pattern-single: - match: { error.type: "parsing_exception" } - contains: { error.reason: "line 1:36: invalid index pattern [test-lookup-1*], * is not allowed in LOOKUP JOIN" } + +--- +mv-on-lookup: + - do: + esql.query: + body: + query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-mv ON key' + allowed_warnings: + - "No limit defined, adding default limit of [1000]" + - "Line 1:24: evaluation of [LOOKUP JOIN test-lookup-mv ON key] failed, treating result as null. Only first 20 failures recorded." + - "Line 1:24: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value" + + - match: {columns.0.name: "key"} + - match: {columns.0.type: "long"} + - match: {columns.1.name: "color"} + - match: {columns.1.type: "keyword"} + - match: {values.0: [1, "cyan"]} + - match: {values.1: [2, "yellow"]} + +--- +mv-on-query: + - do: + esql.query: + body: + query: 'FROM test-mv | SORT key | LOOKUP JOIN test-lookup-1 ON key | LIMIT 4' + allowed_warnings: + - "Line 1:27: evaluation of [LOOKUP JOIN test-lookup-1 ON key] failed, treating result as null. Only first 20 failures recorded." + - "Line 1:27: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value" + + - match: {columns.0.name: "key"} + - match: {columns.0.type: "long"} + - match: {columns.1.name: "color"} + - match: {columns.1.type: "keyword"} + - match: {values.0: [[0, 1, 2], null]} + - match: {values.1: [1, "cyan"]} + - match: {values.2: [2, "yellow"]} + +--- +lookup-no-key: + - do: + esql.query: + body: + query: 'FROM test | LOOKUP JOIN test-lookup-no-key ON key | KEEP key, color' + catch: "bad_request" + + - match: { error.type: "verification_exception" } + - contains: { error.reason: "Unknown column [key] in right side of join" } From 67240a5c0e212f9270f5aedf3379e347cd73f168 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Sun, 11 May 2025 10:40:05 +0200 Subject: [PATCH 2/2] Fix mistake in merge --- .../test/esql/190_lookup_join.yml | 85 +------------------ 1 file changed, 2 insertions(+), 83 deletions(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml index 40c6db728a2e1..b148bb4aa422c 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml @@ -1,12 +1,12 @@ --- setup: - requires: - test_runner_features: [capabilities, contains, allowed_warnings] + test_runner_features: [capabilities, contains] capabilities: - method: POST path: /_query parameters: [] - capabilities: [join_lookup_v12, join_lookup_skip_mv_warnings] + capabilities: [join_lookup_v12] reason: "uses LOOKUP JOIN" - do: indices.create: @@ -18,16 +18,6 @@ setup: type: long color: type: keyword - - do: - indices.create: - index: test-mv - body: - mappings: - properties: - key: - type: long - color: - type: keyword - do: indices.create: index: test-lookup-1 @@ -54,19 +44,6 @@ setup: type: long color: type: keyword - - do: - indices.create: - index: test-lookup-mv - body: - settings: - index: - mode: lookup - mappings: - properties: - key: - type: long - color: - type: keyword - do: indices.create: index: test-lookup-no-key @@ -111,28 +88,6 @@ setup: - { "key": 1, "color": "cyan" } - { "index": { } } - { "key": 2, "color": "yellow" } - - do: - bulk: - index: "test-mv" - refresh: true - body: - - { "index": { } } - - { "key": 1, "color": "red" } - - { "index": { } } - - { "key": 2, "color": "blue" } - - { "index": { } } - - { "key": [0, 1, 2], "color": null } - - do: - bulk: - index: "test-lookup-mv" - refresh: true - body: - - { "index": { } } - - { "key": 1, "color": "cyan" } - - { "index": { } } - - { "key": 2, "color": "yellow" } - - { "index": { } } - - { "key": [0, 1, 2], "color": "green" } - do: bulk: index: "test-lookup-no-key" @@ -268,42 +223,6 @@ pattern-single: - match: { error.type: "parsing_exception" } - contains: { error.reason: "line 1:36: invalid index pattern [test-lookup-1*], * is not allowed in LOOKUP JOIN" } ---- -mv-on-lookup: - - do: - esql.query: - body: - query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-mv ON key' - allowed_warnings: - - "No limit defined, adding default limit of [1000]" - - "Line 1:24: evaluation of [LOOKUP JOIN test-lookup-mv ON key] failed, treating result as null. Only first 20 failures recorded." - - "Line 1:24: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value" - - - match: {columns.0.name: "key"} - - match: {columns.0.type: "long"} - - match: {columns.1.name: "color"} - - match: {columns.1.type: "keyword"} - - match: {values.0: [1, "cyan"]} - - match: {values.1: [2, "yellow"]} - ---- -mv-on-query: - - do: - esql.query: - body: - query: 'FROM test-mv | SORT key | LOOKUP JOIN test-lookup-1 ON key | LIMIT 4' - allowed_warnings: - - "Line 1:27: evaluation of [LOOKUP JOIN test-lookup-1 ON key] failed, treating result as null. Only first 20 failures recorded." - - "Line 1:27: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value" - - - match: {columns.0.name: "key"} - - match: {columns.0.type: "long"} - - match: {columns.1.name: "color"} - - match: {columns.1.type: "keyword"} - - match: {values.0: [[0, 1, 2], null]} - - match: {values.1: [1, "cyan"]} - - match: {values.2: [2, "yellow"]} - --- lookup-no-key: - do: