Skip to content

Commit a8ce7b9

Browse files
committed
addressing PR comments - adding test cases for no branches in fork and chaining fuse after a one-branch fork
1 parent 2739004 commit a8ce7b9

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/FuseIT.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.support.WriteRequest;
1212
import org.elasticsearch.common.settings.Settings;
1313
import org.elasticsearch.plugins.Plugin;
14+
import org.elasticsearch.xpack.esql.plan.logical.fuse.Fuse;
1415
import org.junit.Before;
1516

1617
import java.util.Collection;
@@ -163,6 +164,30 @@ public void testFuseLinearWithWeightsAndNormalizer() {
163164
}
164165
}
165166

167+
public void testFuseWithSingleFork() {
168+
for (Fuse.FuseType type : Fuse.FuseType.values()) {
169+
var query = """
170+
FROM test METADATA _score, _id, _index
171+
| WHERE id > 2
172+
| FORK
173+
( WHERE content:"fox" | SORT _score, _id DESC )
174+
| FUSE
175+
""" + type.name() + """
176+
| SORT _score DESC, _id, _index
177+
| EVAL _fork = mv_sort(_fork)
178+
| EVAL _score = round(_score, 4)
179+
| KEEP id, content, _fork
180+
""";
181+
try (var resp = run(query)) {
182+
assertColumnNames(resp.columns(), List.of("id", "content", "_fork"));
183+
assertColumnTypes(resp.columns(), List.of("integer", "keyword", "keyword"));
184+
assertThat(getValuesList(resp.values()).size(), equalTo(1));
185+
Iterable<Iterable<Object>> expectedValues = List.of(List.of(6, "The quick brown fox jumps over the lazy dog", "fork1"));
186+
assertValues(resp.values(), expectedValues);
187+
}
188+
}
189+
}
190+
166191
private void createAndPopulateIndex() {
167192
var indexName = "test";
168193
var client = client().admin().indices();

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3861,6 +3861,13 @@ public void testForkAllCommands() {
38613861
}
38623862

38633863
public void testInvalidFork() {
3864+
expectError("""
3865+
FROM foo* | FORK
3866+
""", "line 2:1: mismatched input '<EOF>' expecting '('");
3867+
expectError("""
3868+
FROM foo* | FORK ()
3869+
""", "line 1:19: mismatched input ')'");
3870+
38643871
expectError("""
38653872
FROM foo*
38663873
| FORK (where true) (where true) (where true) (where true)

0 commit comments

Comments
 (0)