Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](nereids) fix The children format needs to be [WhenClause+, DefaultValue?] #38491

Merged
merged 8 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,12 @@ public Expression visit(Expression expr, C context) {
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) {
Expand Down
38 changes: 38 additions & 0 deletions regression-test/suites/nereids_syntax_p0/join.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,42 @@ suite("join") {
"""

order_qt_test "SELECT * FROM lineorder RIGHT SEMI JOIN supplier ON lineorder.lo_suppkey = supplier.s_suppkey and s_name='Supplier#000000029';"

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;
"""
}
Loading