This is an automated email from the ASF dual-hosted git repository.
huajianlan pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 1ba1e343bdc [fix](nereids) fix The children format needs to be
[WhenClause+, DefaultValue?] (#38491) (#38546)
1ba1e343bdc is described below
commit 1ba1e343bdc2076b66ee52de6d37fc48e18bc781
Author: 924060929 <[email protected]>
AuthorDate: Tue Jul 30 23:51:18 2024 +0800
[fix](nereids) fix The children format needs to be [WhenClause+,
DefaultValue?] (#38491) (#38546)
fix The children format needs to be [WhenClause+, DefaultValue?]
---
.../visitor/DefaultExpressionRewriter.java | 7 ++++
.../suites/nereids_syntax_p0/join.groovy | 38 ++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/DefaultExpressionRewriter.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/DefaultExpressionRewriter.java
index fd25f9368ef..9e86ebb2157 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/DefaultExpressionRewriter.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/DefaultExpressionRewriter.java
@@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.expressions.visitor;
import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.WhenClause;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
@@ -33,6 +34,12 @@ public abstract class DefaultExpressionRewriter<C> extends
ExpressionVisitor<Exp
return rewriteChildren(this, expr, context);
}
+ @Override
+ public Expression visitWhenClause(WhenClause whenClause, C context) {
+ // should not rewrite when clause to other expression because CaseWhen
require WhenClause as children
+ return rewriteChildren(this, whenClause, context);
+ }
+
/** rewriteChildren */
public static final <E extends Expression, C> E rewriteChildren(
ExpressionVisitor<Expression, C> rewriter, E expr, C context) {
diff --git a/regression-test/suites/nereids_syntax_p0/join.groovy
b/regression-test/suites/nereids_syntax_p0/join.groovy
index 63382c3ed44..65eddd01d73 100644
--- a/regression-test/suites/nereids_syntax_p0/join.groovy
+++ b/regression-test/suites/nereids_syntax_p0/join.groovy
@@ -271,4 +271,42 @@ suite("join") {
where
ref_2.`id` is not NULL
"""
+
+ multi_sql """
+ drop table if exists table_test1;
+ drop table if exists table_test2;
+
+ CREATE TABLE table_test1 (
+ id VARCHAR(20) NULL,
+ long1 BIGINT NULL,
+ long2 BIGINT NULL,
+ ) ENGINE=OLAP
+ DUPLICATE KEY(id)
+ COMMENT 'olap'
+ DISTRIBUTED BY HASH(id) BUCKETS AUTO
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+
+ CREATE TABLE table_test2 (
+ id VARCHAR(20) NULL,
+ re_long_4 BIGINT NULL,
+ ) ENGINE=OLAP
+ DUPLICATE KEY(id)
+ COMMENT 'olap'
+ DISTRIBUTED BY HASH(id) BUCKETS AUTO
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+
+ SELECT 1
+ from table_test1 b
+ WHERE (
+ CASE
+ WHEN b.long2=(SELECT re_long_4 FROM table_test2 limit 1) THEN
(select long1 from table_test1 limit 1 )
+ WHEN b.long2=(SELECT re_long_4 FROM table_test2 limit 1) THEN
(select long1 from table_test1 limit 1)
+ ELSE b.long2
+ END
+ )>0;
+ """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]