From 134a152c54b4f245e11d86ee5d0d3ff182ac6666 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Fri, 13 Dec 2024 16:55:51 +0100 Subject: [PATCH] Added tests for wildcard KEEP --- .../session/IndexResolverFieldNamesTests.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/IndexResolverFieldNamesTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/IndexResolverFieldNamesTests.java index 2bb5376d3545c..f8cd914a82973 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/IndexResolverFieldNamesTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/IndexResolverFieldNamesTests.java @@ -1384,6 +1384,19 @@ public void testLookupJoinKeep() { ); } + public void testLookupJoinKeepWildcard() { + assertFieldNames( + """ + FROM employees + | KEEP languages + | RENAME languages AS language_code + | LOOKUP JOIN languages_lookup ON language_code + | KEEP language*""", + Set.of("language*", "languages", "languages.*", "language_code", "language_code.*"), + Set.of() // Since we have KEEP after the LOOKUP, we can use the global field names instead of wildcarding the lookup index + ); + } + public void testMultiLookupJoin() { assertFieldNames( """ @@ -1459,6 +1472,19 @@ public void testMultiLookupJoinKeepAfter() { ); } + public void testMultiLookupJoinKeepAfterWildcard() { + assertFieldNames( + """ + FROM sample_data + | EVAL client_ip = client_ip::keyword + | LOOKUP JOIN clientips_lookup ON client_ip + | LOOKUP JOIN message_types_lookup ON message + | KEEP *env*, *type*""", + Set.of("*env*", "*type*", "client_ip", "message", "client_ip.*", "message.*"), + Set.of() // Since the KEEP is after both JOINs, we can use the global field names + ); + } + public void testMultiLookupJoinSameIndex() { assertFieldNames( """