浏览代码

Refine error messages in `Fork` for correctness and clarity. (#131701)

Refine error messages in `Fork` for correctness and clarity.
Michael Bischoff 3 月之前
父节点
当前提交
f1e42c300d

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

@@ -1017,7 +1017,7 @@ public class ForkIT extends AbstractEsqlIntegTestCase {
                    ( FORK (WHERE true) (WHERE true) )
             """;
         var e = expectThrows(VerificationException.class, () -> run(query));
-        assertTrue(e.getMessage().contains("Only a single FORK command is allowed, but found multiple"));
+        assertTrue(e.getMessage().contains("Only a single FORK command is supported, but found multiple"));
     }
 
     public void testProfile() {
@@ -1054,7 +1054,7 @@ public class ForkIT extends AbstractEsqlIntegTestCase {
                    (WHERE true) (WHERE true) (WHERE true) (WHERE true)
             """;
         var e = expectThrows(ParsingException.class, () -> run(query));
-        assertTrue(e.getMessage().contains("Fork requires less than 8 branches"));
+        assertTrue(e.getMessage().contains("Fork supports up to 8 branches"));
 
     }
 

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

@@ -678,7 +678,7 @@ public class LogicalPlanBuilder extends ExpressionBuilder {
             throw new ParsingException(source(ctx), "Fork requires at least " + Fork.MIN_BRANCHES + " branches");
         }
         if (subQueries.size() > Fork.MAX_BRANCHES) {
-            throw new ParsingException(source(ctx), "Fork requires less than " + Fork.MAX_BRANCHES + " branches");
+            throw new ParsingException(source(ctx), "Fork supports up to " + Fork.MAX_BRANCHES + " branches");
         }
 
         return input -> {

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

@@ -46,7 +46,7 @@ public class Fork extends LogicalPlan implements PostAnalysisPlanVerificationAwa
             throw new IllegalArgumentException("FORK requires more than " + MIN_BRANCHES + " branches, got: " + children.size());
         }
         if (children.size() > MAX_BRANCHES) {
-            throw new IllegalArgumentException("FORK requires less than " + MAX_BRANCHES + " subqueries, got: " + children.size());
+            throw new IllegalArgumentException("FORK supports up to " + MAX_BRANCHES + " branches, got: " + children.size());
         }
 
         this.output = output;
@@ -192,7 +192,7 @@ public class Fork extends LogicalPlan implements PostAnalysisPlanVerificationAwa
                 return;
             }
 
-            failures.add(Failure.fail(otherFork, "Only a single FORK command is allowed, but found multiple"));
+            failures.add(Failure.fail(otherFork, "Only a single FORK command is supported, but found multiple"));
         });
 
         Map<String, DataType> outputTypes = fork.output().stream().collect(Collectors.toMap(Attribute::name, Attribute::dataType));

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

@@ -3394,14 +3394,14 @@ public class AnalyzerTests extends ESTestCase {
             | FORK (EVAL a = 1) (EVAL a = 2)
             | FORK (EVAL b = 3) (EVAL b = 4)
             """));
-        assertThat(e.getMessage(), containsString("Only a single FORK command is allowed, but found multiple"));
+        assertThat(e.getMessage(), containsString("Only a single FORK command is supported, but found multiple"));
 
         e = expectThrows(VerificationException.class, () -> analyze("""
             FROM test
             | FORK (FORK (WHERE true) (WHERE true))
                    (WHERE true)
             """));
-        assertThat(e.getMessage(), containsString("Only a single FORK command is allowed, but found multiple"));
+        assertThat(e.getMessage(), containsString("Only a single FORK command is supported, but found multiple"));
     }
 
     public void testValidFuse() {

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

@@ -3645,7 +3645,7 @@ public class StatementParserTests extends AbstractStatementParserTests {
             | FORK (where true) (where true) (where true) (where true)
                    (where true) (where true) (where true) (where true)
                    (where true)
-            """, "Fork requires less than 8 branches");
+            """, "Fork supports up to 8 branches");
 
         expectError("FROM foo* | FORK ( x+1 ) ( WHERE y>2 )", "line 1:20: mismatched input 'x+1'");
         expectError("FROM foo* | FORK ( LIMIT 10 ) ( y+2 )", "line 1:33: mismatched input 'y+2'");