Skip to content

Commit 0ee2d30

Browse files
committed
Update tests
1 parent 22401b3 commit 0ee2d30

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public abstract class GenerativeRestTest extends ESRestTestCase {
5555
"optimized incorrectly due to missing references", // https://github.com/elastic/elasticsearch/issues/116781
5656
"No matches found for pattern", // https://github.com/elastic/elasticsearch/issues/126418
5757
"Unknown column", // https://github.com/elastic/elasticsearch/issues/127467
58-
"only supports KEYWORD or TEXT values", // https://github.com/elastic/elasticsearch/issues/127468
5958
"The incoming YAML document exceeds the limit:" // still to investigate, but it seems to be specific to the test framework
6059
);
6160

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,19 @@ ROW a="b c d x"| DISSECT a "%{b} %{} %{d} %{}";
331331
a:keyword | b:keyword | d:keyword
332332
b c d x | b | d
333333
;
334+
335+
avoidAttributesRemoval
336+
required_capability: keep_regex_extract_attributes
337+
required_capability: join_lookup_v12
338+
from message_types
339+
| eval type = 1
340+
| lookup join message_types_lookup on message
341+
| drop message
342+
| dissect type "%{b}"
343+
| stats x = max(b)
344+
| keep x
345+
;
346+
347+
x:keyword
348+
Success
349+
;

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,34 @@ row text = "123 abc", int = 5 | sort int asc | grok text "%{NUMBER:text:int} %{W
297297
text:integer | int:integer | description:keyword
298298
123 | 5 | abc
299299
;
300+
301+
avoidAttributesRemoval
302+
required_capability: union_types
303+
required_capability: join_lookup_v12
304+
required_capability: keep_regex_extract_attributes
305+
from multivalue_points,h*,messa*
306+
| eval `card` = true, PbehoQUqKSF = "VLGjhcgNkQiEVyCLo", DsxMWtGL = true, qSxTIvUorMim = true, `location` = 8593178066470220111, type = -446161601, FSkGQkgmS = false
307+
| eval PbehoQUqKSF = 753987034, HLNMQfQj = true, `within` = true, `id` = "JDKKkYwhhh", lk = null, aecuvjTkgZza = 510616700, aDAMpuVtNX = null, qCopgNZPt = "AjhJUtZefqKdJYH", BxHHlFoA = "isBrmhKLc"
308+
| rename message as message
309+
| lookup join message_types_lookup on message
310+
| sort PbehoQUqKSF DESC, ip1 DESC NULLS LAST
311+
| limit 5845
312+
| drop `subset`, ip*, `card`, `within`, host.v*, description, `aecuvjTkgZza`, host.version, `ip0`, height_range, DsxMWtGL, host_group, `aDAMpuVtNX`, PbehoQUqKSF, `intersects`, `host.os`, aDAMpuVtNX, *ight_range, HLNMQfQj, `FSkGQkgmS`, BxHHlFoA, card
313+
| grok type "%{WORD:GknCxQFo}"
314+
| eval `location` = null, ZjWUUvGusyyz = null, HeeKIpzgh = false, `id` = 4325287503714500302, host = false, `lk` = null, HvTQdOqFajpH = false, fKNlsYoT = true, `location` = -1158449473, `qCopgNZPt` = 1219986202615280617
315+
| drop HeeKIpzg*, `ZjWUUvGusyyz`, `message`, `type`, `lk`
316+
| grok GknCxQFo "%{WORD:location} %{WORD:HvTQdOqFajpH}"
317+
| drop HvTQdOqFajpH, `location`, centroid
318+
| mv_expand GknCxQFo
319+
| limit 410
320+
| limit 3815
321+
| rename `id` AS `GknCxQFo`
322+
| grok host.name "%{WORD:oGQQZHxQHj} %{WORD:qCopgNZPt} %{WORD:vHKOmmocPcTO}"
323+
| stats BkQXJRMeAM = min(GknCxQFo)
324+
| keep `BkQXJRMeAM`
325+
;
326+
327+
BkQXJRMeAM:long
328+
4325287503714500000
329+
;
330+

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ public enum Cap {
369369
*/
370370
GROK_DISSECT_MASKING,
371371

372+
/**
373+
* Avid GROK and DISSECT attributes being removed when resolving fields.
374+
* see <a href="https://github.com/elastic/elasticsearch/issues/127468"> ES|QL: Grok only supports KEYWORD or TEXT values, found expression [type] type [INTEGER] #127468 </a>
375+
*/
376+
KEEP_REGEX_EXTRACT_ATTRIBUTES,
372377
/**
373378
* Support for quoting index sources in double quotes.
374379
*/

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/IndexResolverFieldNamesTests.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ public void testEvalDissect() {
267267
| dissect full_name "%{a} %{b}"
268268
| sort emp_no asc
269269
| keep full_name, a, b
270-
| limit 3""", Set.of("first_name", "first_name.*", "last_name", "last_name.*", "emp_no", "emp_no.*"));
270+
| limit 3""",
271+
Set.of("emp_no", "first_name", "last_name", "full_name", "last_name.*", "first_name.*", "full_name.*", "emp_no.*")
272+
);
271273
}
272274

273275
public void testDissectExpression() {
@@ -691,7 +693,9 @@ public void testEvalGrok() {
691693
| grok full_name "%{WORD:a} %{WORD:b}"
692694
| sort emp_no asc
693695
| keep full_name, a, b
694-
| limit 3""", Set.of("first_name", "first_name.*", "last_name", "last_name.*", "emp_no", "emp_no.*"));
696+
| limit 3""",
697+
Set.of("emp_no", "first_name", "last_name", "full_name", "last_name.*", "first_name.*", "full_name.*", "emp_no.*")
698+
);
695699
}
696700

697701
public void testGrokExpression() {
@@ -710,7 +714,7 @@ public void testEvalGrokSort() {
710714
| grok full_name "%{WORD:a} %{WORD:b}"
711715
| sort a asc
712716
| keep full_name, a, b
713-
| limit 3""", Set.of("first_name", "first_name.*", "last_name", "last_name.*"));
717+
| limit 3""", Set.of("first_name", "last_name", "full_name", "last_name.*", "first_name.*", "full_name.*"));
714718
}
715719

716720
public void testGrokStats() {
@@ -720,7 +724,7 @@ public void testGrokStats() {
720724
| grok x "%{WORD:a} %{WORD:b}"
721725
| stats n = max(emp_no) by a
722726
| keep a, n
723-
| sort a asc""", Set.of("gender", "gender.*", "emp_no", "emp_no.*"));
727+
| sort a asc""", Set.of("emp_no", "gender", "x", "x.*", "gender.*", "emp_no.*"));
724728
}
725729

726730
public void testNullOnePattern() {
@@ -1341,6 +1345,18 @@ public void testDissectOverwriteName() {
13411345
assertThat(fieldNames, equalTo(Set.of("emp_no", "emp_no.*", "first_name", "first_name.*")));
13421346
}
13431347

1348+
public void testAvoidGrokAttributesRemoval() {
1349+
Set<String> fieldNames = fieldNames("""
1350+
from message_types
1351+
| eval type = 1
1352+
| lookup join message_types_lookup on message
1353+
| drop message
1354+
| grok type "%{WORD:b}"
1355+
| stats x = max(b)
1356+
| keep x""", Set.of());
1357+
assertThat(fieldNames, equalTo(Set.of("message", "x", "type", "x.*", "message.*", "type.*")));
1358+
}
1359+
13441360
public void testEnrichOnDefaultField() {
13451361
Set<String> fieldNames = fieldNames("""
13461362
from employees

0 commit comments

Comments
 (0)