Skip to content

Commit 6378f76

Browse files
Add tests
1 parent 300f169 commit 6378f76

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,34 @@ public void testSingleFork() {
21992199
| SORT _fork""", IndexResolver.ALL_FIELDS);
22002200
}
22012201

2202+
public void testForkRefs1() {
2203+
assertFieldNames("""
2204+
FROM employees
2205+
| KEEP first_name, last_name
2206+
| FORK
2207+
( EVAL x = first_name)
2208+
( EVAL x = last_name)
2209+
""", Set.of("first_name", "last_name", "last_name.*", "first_name.*"));
2210+
}
2211+
2212+
public void testForkRefs2() {
2213+
assertFieldNames("""
2214+
FROM employees
2215+
| FORK
2216+
( KEEP first_name | EVAL x = first_name)
2217+
( KEEP last_name | EVAL x = last_name)
2218+
""", Set.of("first_name", "last_name", "last_name.*", "first_name.*"));
2219+
}
2220+
2221+
public void testForkRefs3() {
2222+
assertFieldNames("""
2223+
FROM employees
2224+
| FORK
2225+
( KEEP first_name | EVAL last_name = first_name)
2226+
( KEEP first_name | EVAL x = first_name)
2227+
""", Set.of("first_name", "first_name.*"));
2228+
}
2229+
22022230
private void assertFieldNames(String query, Set<String> expected) {
22032231
assertFieldNames(query, new EnrichResolution(), expected, Set.of());
22042232
}

0 commit comments

Comments
 (0)