diff --git a/muted-tests.yml b/muted-tests.yml index 0aa7d2253a936..e9c42de31d6fc 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -507,18 +507,6 @@ tests: - class: org.elasticsearch.index.store.DirectIOIT method: testDirectIOUsed issue: https://github.com/elastic/elasticsearch/issues/128829 -- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT - method: test {p0=esql/190_lookup_join/alias-repeated-index} - issue: https://github.com/elastic/elasticsearch/issues/128849 -- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT - method: test {p0=esql/190_lookup_join/alias-repeated-alias} - issue: https://github.com/elastic/elasticsearch/issues/128850 -- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT - method: test {p0=esql/190_lookup_join/alias-pattern-single} - issue: https://github.com/elastic/elasticsearch/issues/128855 -- class: org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT - method: test {p0=esql/191_lookup_join_on_datastreams/data streams supported in LOOKUP JOIN} - issue: https://github.com/elastic/elasticsearch/issues/128856 - class: org.elasticsearch.upgrades.IndexSortUpgradeIT method: testIndexSortForNumericTypes {upgradedNodes=3} issue: https://github.com/elastic/elasticsearch/issues/128861 diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index dc1e7e9a8e424..1687189d92c01 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1164,7 +1164,7 @@ public enum Cap { /** * Enable support for index aliases in lookup joins */ - ENABLE_LOOKUP_JOIN_ON_ALIASES(JOIN_LOOKUP_V12.isEnabled()); + ENABLE_LOOKUP_JOIN_ON_ALIASES; private final boolean enabled; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java index f21dd5eedb1b2..72859b6210871 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java @@ -203,7 +203,7 @@ public void writeTo(StreamOutput out) throws IOException { || out.getTransportVersion().isPatchFrom(TransportVersions.JOIN_ON_ALIASES_8_19)) { out.writeString(indexPattern); } else if (indexPattern.equals(shardId.getIndexName()) == false) { - throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN []", indexPattern); + throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN [{}]", indexPattern); } out.writeString(inputDataType.typeName()); 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 fdd11840b7a27..c66105e959392 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 @@ -6,7 +6,7 @@ setup: - method: POST path: /_query parameters: [] - capabilities: [join_lookup_v12, enable_lookup_join_on_aliases] + capabilities: [join_lookup_v12] reason: "uses LOOKUP JOIN" - do: indices.create: @@ -80,19 +80,6 @@ setup: type: long color: type: keyword - - do: - indices.update_aliases: - body: - actions: - - add: - index: test-lookup-1 - alias: test-lookup-alias - - add: - index: test-lookup-* - alias: test-lookup-alias-pattern-multiple - - add: - index: test-lookup-1* - alias: test-lookup-alias-pattern-single - do: bulk: index: "test" @@ -168,76 +155,6 @@ non-lookup index: - match: { error.type: "verification_exception" } - contains: { error.reason: "Found 1 problem\nline 1:45: invalid [test] resolution in lookup mode to an index in [standard] mode" } ---- - -"Alias as lookup index": - - skip: - awaits_fix: "LOOKUP JOIN does not support index aliases for now" - - do: - esql.query: - body: - query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' - - - 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"]} - ---- -alias-repeated-alias: - - do: - esql.query: - body: - query: 'FROM test-lookup-alias | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' - - - 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"]} - ---- -alias-repeated-index: - - do: - esql.query: - body: - query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' - - - 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"]} - ---- -alias-pattern-multiple: - - do: - esql.query: - body: - query: 'FROM test-lookup-1 | LOOKUP JOIN test-lookup-alias-pattern-multiple ON key' - catch: "bad_request" - - - match: { error.type: "verification_exception" } - - contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [4] indices" } - ---- -alias-pattern-single: - - do: - esql.query: - body: - query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias-pattern-single ON key | LIMIT 3' - - - 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"]} - --- pattern-multiple: - do: diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/192_lookup_join_on_aliases.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/192_lookup_join_on_aliases.yml new file mode 100644 index 0000000000000..c77f92e72c159 --- /dev/null +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/192_lookup_join_on_aliases.yml @@ -0,0 +1,211 @@ +--- +setup: + - requires: + test_runner_features: [capabilities, contains, allowed_warnings] + capabilities: + - method: POST + path: /_query + parameters: [] + capabilities: [enable_lookup_join_on_aliases] + reason: "uses LOOKUP JOIN on aliases" + - do: + indices.create: + index: test + body: + mappings: + properties: + key: + 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 + body: + settings: + index: + mode: lookup + mappings: + properties: + key: + type: long + color: + type: keyword + - do: + indices.create: + index: test-lookup-2 + body: + settings: + index: + mode: lookup + mappings: + properties: + key: + 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: + actions: + - add: + index: test-lookup-1 + alias: test-lookup-alias + - add: + index: test-lookup-* + alias: test-lookup-alias-pattern-multiple + - add: + index: test-lookup-1* + alias: test-lookup-alias-pattern-single + - do: + bulk: + index: "test" + refresh: true + body: + - { "index": { } } + - { "key": 1, "color": "red" } + - { "index": { } } + - { "key": 2, "color": "blue" } + - do: + bulk: + index: "test-lookup-1" + refresh: true + body: + - { "index": { } } + - { "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" } + +--- +alias-as-lookup-index: + - do: + esql.query: + body: + query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' + + - 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"]} + +--- +alias-repeated-alias: + - do: + esql.query: + body: + query: 'FROM test-lookup-alias | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' + + - 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"]} + +--- +alias-repeated-index: + - do: + esql.query: + body: + query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3' + + - 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"]} + +--- +alias-pattern-multiple: + - do: + esql.query: + body: + query: 'FROM test-lookup-1 | LOOKUP JOIN test-lookup-alias-pattern-multiple ON key' + catch: "bad_request" + + - match: { error.type: "verification_exception" } + - contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [4] indices" } + +--- +alias-pattern-single: + - do: + esql.query: + body: + query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias-pattern-single ON key | LIMIT 3' + + - 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"]} diff --git a/x-pack/qa/multi-project/xpack-rest-tests-with-multiple-projects/build.gradle b/x-pack/qa/multi-project/xpack-rest-tests-with-multiple-projects/build.gradle index 50f54c717a13f..2a4ea94789162 100644 --- a/x-pack/qa/multi-project/xpack-rest-tests-with-multiple-projects/build.gradle +++ b/x-pack/qa/multi-project/xpack-rest-tests-with-multiple-projects/build.gradle @@ -46,6 +46,7 @@ tasks.named("yamlRestTest").configure { '^esql/190_lookup_join/*', '^esql/191_lookup_join_on_datastreams/*', '^esql/191_lookup_join_text/*', + '^esql/192_lookup_join_on_aliases/*', '^health/10_usage/*', '^ilm/10_basic/Test Undeletable Policy In Use', '^ilm/20_move_to_step/*',