This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 58c0a2552eb [fix](Nereids) check slot from children may produce wrong 
format err (#31638) (#31670)
58c0a2552eb is described below

commit 58c0a2552eb6164cb037da738a97cbab03f8bbe7
Author: morrySnow <[email protected]>
AuthorDate: Mon Mar 4 11:53:33 2024 +0800

    [fix](Nereids) check slot from children may produce wrong format err 
(#31638) (#31670)
    
    pick from master #31638
    commit id 8a1bc8b82f966b6de63809667c7255afb84f95b9
---
 .../doris/nereids/rules/analysis/CheckAfterRewrite.java      | 12 +++++++-----
 regression-test/suites/nereids_p0/aggregate/aggregate.groovy |  8 ++++++++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAfterRewrite.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAfterRewrite.java
index 0d7c953bb7f..c4bf4fc0d15 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAfterRewrite.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAfterRewrite.java
@@ -106,16 +106,18 @@ public class CheckAfterRewrite extends 
OneAnalysisRuleFactory {
         notFromChildren = removeValidSlotsNotFromChildren(notFromChildren, 
childrenOutput);
         if (!notFromChildren.isEmpty()) {
             if (plan.arity() != 0 && plan.child(0) instanceof 
LogicalAggregate) {
-                throw new AnalysisException(String.format("%s not in agg's 
output", notFromChildren
+                throw new AnalysisException(String.format("%s not in 
aggregate's output", notFromChildren
                         
.stream().map(NamedExpression::getName).collect(Collectors.joining(", "))));
             } else {
                 throw new AnalysisException(String.format(
-                        "Input slot(s) not in child's output: %s in plan: %s,"
-                                + " child output is: %s\n" + "plan tree:\n" + 
plan.treeString(),
+                        "Input slot(s) not in child's output: %s in plan: 
%s\nchild output is: %s\nplan tree:\n%s",
                         
StringUtils.join(notFromChildren.stream().map(ExpressionTrait::toString)
                                 .collect(Collectors.toSet()), ", "),
-                        plan, plan.children().stream().flatMap(child -> 
child.getOutput().stream())
-                                .collect(Collectors.toSet())));
+                        plan,
+                        plan.children().stream()
+                                .flatMap(child -> child.getOutput().stream())
+                                .collect(Collectors.toSet()),
+                        plan.treeString()));
             }
         }
     }
diff --git a/regression-test/suites/nereids_p0/aggregate/aggregate.groovy 
b/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
index 63b1a7256bb..cf8b51d328c 100644
--- a/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
@@ -329,6 +329,14 @@ suite("aggregate") {
     assertTrue(plan.contains("min(c_bigint"))
     assertTrue(plan.contains("any_value(c_bigint"))
 
+    test {
+        sql """
+              SELECT k1, k2 FROM tempbaseall
+              GROUP BY k1;
+            """
+        exception "k2 not in aggregate's output"
+    }
+
     test {
         sql """
               SELECT sum(avg(k1)) FROM tempbaseall;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to