Skip to content

Commit f1e42c3

Browse files
authored
Refine error messages in Fork for correctness and clarity. (#131701)
Refine error messages in `Fork` for correctness and clarity.
1 parent 33fbe66 commit f1e42c3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ public void testForkWithinFork() {
10171017
( FORK (WHERE true) (WHERE true) )
10181018
""";
10191019
var e = expectThrows(VerificationException.class, () -> run(query));
1020-
assertTrue(e.getMessage().contains("Only a single FORK command is allowed, but found multiple"));
1020+
assertTrue(e.getMessage().contains("Only a single FORK command is supported, but found multiple"));
10211021
}
10221022

10231023
public void testProfile() {
@@ -1054,7 +1054,7 @@ public void testWithTooManySubqueries() {
10541054
(WHERE true) (WHERE true) (WHERE true) (WHERE true)
10551055
""";
10561056
var e = expectThrows(ParsingException.class, () -> run(query));
1057-
assertTrue(e.getMessage().contains("Fork requires less than 8 branches"));
1057+
assertTrue(e.getMessage().contains("Fork supports up to 8 branches"));
10581058

10591059
}
10601060

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ public PlanFactory visitForkCommand(EsqlBaseParser.ForkCommandContext ctx) {
678678
throw new ParsingException(source(ctx), "Fork requires at least " + Fork.MIN_BRANCHES + " branches");
679679
}
680680
if (subQueries.size() > Fork.MAX_BRANCHES) {
681-
throw new ParsingException(source(ctx), "Fork requires less than " + Fork.MAX_BRANCHES + " branches");
681+
throw new ParsingException(source(ctx), "Fork supports up to " + Fork.MAX_BRANCHES + " branches");
682682
}
683683

684684
return input -> {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Fork.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Fork(Source source, List<LogicalPlan> children, List<Attribute> output) {
4646
throw new IllegalArgumentException("FORK requires more than " + MIN_BRANCHES + " branches, got: " + children.size());
4747
}
4848
if (children.size() > MAX_BRANCHES) {
49-
throw new IllegalArgumentException("FORK requires less than " + MAX_BRANCHES + " subqueries, got: " + children.size());
49+
throw new IllegalArgumentException("FORK supports up to " + MAX_BRANCHES + " branches, got: " + children.size());
5050
}
5151

5252
this.output = output;
@@ -192,7 +192,7 @@ private static void checkFork(LogicalPlan plan, Failures failures) {
192192
return;
193193
}
194194

195-
failures.add(Failure.fail(otherFork, "Only a single FORK command is allowed, but found multiple"));
195+
failures.add(Failure.fail(otherFork, "Only a single FORK command is supported, but found multiple"));
196196
});
197197

198198
Map<String, DataType> outputTypes = fork.output().stream().collect(Collectors.toMap(Attribute::name, Attribute::dataType));

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,14 +3394,14 @@ public void testForkError() {
33943394
| FORK (EVAL a = 1) (EVAL a = 2)
33953395
| FORK (EVAL b = 3) (EVAL b = 4)
33963396
"""));
3397-
assertThat(e.getMessage(), containsString("Only a single FORK command is allowed, but found multiple"));
3397+
assertThat(e.getMessage(), containsString("Only a single FORK command is supported, but found multiple"));
33983398

33993399
e = expectThrows(VerificationException.class, () -> analyze("""
34003400
FROM test
34013401
| FORK (FORK (WHERE true) (WHERE true))
34023402
(WHERE true)
34033403
"""));
3404-
assertThat(e.getMessage(), containsString("Only a single FORK command is allowed, but found multiple"));
3404+
assertThat(e.getMessage(), containsString("Only a single FORK command is supported, but found multiple"));
34053405
}
34063406

34073407
public void testValidFuse() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3645,7 +3645,7 @@ public void testInvalidFork() {
36453645
| FORK (where true) (where true) (where true) (where true)
36463646
(where true) (where true) (where true) (where true)
36473647
(where true)
3648-
""", "Fork requires less than 8 branches");
3648+
""", "Fork supports up to 8 branches");
36493649

36503650
expectError("FROM foo* | FORK ( x+1 ) ( WHERE y>2 )", "line 1:20: mismatched input 'x+1'");
36513651
expectError("FROM foo* | FORK ( LIMIT 10 ) ( y+2 )", "line 1:33: mismatched input 'y+2'");

0 commit comments

Comments
 (0)