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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new e879ffc8b58 [chore](Variant) forbid variant type as hash join key 
(#41673) (#42377)
e879ffc8b58 is described below

commit e879ffc8b582db3c651222d8d9b8b2e1faf93e66
Author: morrySnow <[email protected]>
AuthorDate: Thu Oct 24 16:28:04 2024 +0800

    [chore](Variant) forbid variant type as hash join key (#41673) (#42377)
    
    pick from master #41673
---
 .../doris/nereids/rules/analysis/CheckAfterRewrite.java     | 13 +++++++++++++
 regression-test/suites/nereids_p0/join/test_join_on.groovy  |  5 +++++
 2 files changed, 18 insertions(+)

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 df8ec64fc2e..562e84275df 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
@@ -41,6 +41,7 @@ import org.apache.doris.nereids.trees.plans.algebra.Generate;
 import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
 import 
org.apache.doris.nereids.trees.plans.logical.LogicalDeferMaterializeOlapScan;
 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.LogicalOlapScan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
 import org.apache.doris.nereids.trees.plans.logical.LogicalTopN;
@@ -179,6 +180,18 @@ public class CheckAfterRewrite extends 
OneAnalysisRuleFactory {
                     throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
                 }
             });
+        } else if (plan instanceof LogicalJoin) {
+            LogicalJoin<?, ?> join = (LogicalJoin<?, ?>) plan;
+            for (Expression conjunct : join.getHashJoinConjuncts()) {
+                if (conjunct.anyMatch(e -> ((Expression) 
e).getDataType().isVariantType())) {
+                    throw new AnalysisException("variant type could not in 
join equal conditions: " + conjunct.toSql());
+                }
+            }
+            for (Expression conjunct : join.getMarkJoinConjuncts()) {
+                if (conjunct.anyMatch(e -> ((Expression) 
e).getDataType().isVariantType())) {
+                    throw new AnalysisException("variant type could not in 
join equal conditions: " + conjunct.toSql());
+                }
+            }
         }
     }
 
diff --git a/regression-test/suites/nereids_p0/join/test_join_on.groovy 
b/regression-test/suites/nereids_p0/join/test_join_on.groovy
index 752467d3028..02b04479e98 100644
--- a/regression-test/suites/nereids_p0/join/test_join_on.groovy
+++ b/regression-test/suites/nereids_p0/join/test_join_on.groovy
@@ -50,4 +50,9 @@ suite("test_join_on", "nereids_p0") {
         sql """ select * from join_on as j1 inner join join_on as j2 on j1.k3 
= j2.k3; """
         exception "data type BITMAP could not used in ComparisonPredicate"
     }
+
+    test {
+        sql """select * from (select cast('' as variant) as a) t1 join (select 
cast('' as variant) as a) t2 on t1.a = t2.a"""
+        exception "variant type could not in join equal conditions"
+    }
 }


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

Reply via email to