You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/06/06 08:50:28 UTC

[doris] branch master updated: [fix](Nereids) give clean error message when there are subquery in the on clause (#20211)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new a569d371b3 [fix](Nereids) give clean error message when there are subquery in the on clause (#20211)
a569d371b3 is described below

commit a569d371b3953f6aef1e5596635f36da5ddc88d1
Author: Chengpeng Yan <41...@users.noreply.github.com>
AuthorDate: Tue Jun 6 16:50:20 2023 +0800

    [fix](Nereids) give clean error message when there are subquery in the on clause (#20211)
    
    Add the rule for checking the join node in `analysis/CheckAnalysis.java` file. When we check the join node, we should check its' on clause. If there are some subquery expression, we should throw exception.
    
    Before this PR
    ```
    mysql> select a.k1 from baseall a join test b on b.k2 in (select 49);
    ERROR 1105 (HY000): errCode = 2, detailMessage = Unexpected exception: nul
    ```
    
    After this PR
    ```
    mysql> select a.k1 from baseall a join test b on b.k2 in (select 49);
    ERROR 1105 (HY000): errCode = 2, detailMessage = Unexpected exception: Not support OnClause contain Subquery, expr:k2 IN (INSUBQUERY) (LogicalOneRowRelation ( projects=[49 AS `49`#28], buildUnionNode=true ))
    ```
---
 .../doris/nereids/rules/analysis/CheckAnalysis.java      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAnalysis.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAnalysis.java
index 80ce746776..c37c05084f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAnalysis.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CheckAnalysis.java
@@ -21,6 +21,7 @@ import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
 import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.SubqueryExpr;
 import org.apache.doris.nereids.trees.expressions.WindowExpression;
 import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.GroupingScalarFunction;
@@ -28,6 +29,7 @@ import org.apache.doris.nereids.trees.expressions.typecoercion.TypeCheckResult;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
 import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
 
 import com.google.common.collect.ImmutableList;
@@ -46,12 +48,14 @@ import java.util.Set;
 public class CheckAnalysis implements AnalysisRuleFactory {
 
     private static final Map<Class<? extends LogicalPlan>, Set<Class<? extends Expression>>>
-            UNEXPECTED_EXPRESSION_TYPE_MAP = ImmutableMap.of(
-                    LogicalFilter.class, ImmutableSet.of(
-                            AggregateFunction.class,
-                            GroupingScalarFunction.class,
-                            WindowExpression.class)
-    );
+            UNEXPECTED_EXPRESSION_TYPE_MAP = ImmutableMap.<Class<? extends LogicalPlan>,
+                Set<Class<? extends Expression>>>builder()
+            .put(LogicalFilter.class, ImmutableSet.of(
+                AggregateFunction.class,
+                GroupingScalarFunction.class,
+                WindowExpression.class))
+            .put(LogicalJoin.class, ImmutableSet.of(SubqueryExpr.class))
+            .build();
 
     @Override
     public List<Rule> buildRules() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org