This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 8ead097e527 [fix](planner)implicit cast should use type member variable instead of targetTypeDef (#24582) (#31013) 8ead097e527 is described below commit 8ead097e527f85e6b183ef2d77a00f15d625f735 Author: Mingyu Chen <morning...@163.com> AuthorDate: Fri Feb 9 17:40:40 2024 +0800 [fix](planner)implicit cast should use type member variable instead of targetTypeDef (#24582) (#31013) bp #24582 --- .../java/org/apache/doris/analysis/CastExpr.java | 3 +- .../suites/correctness_p0/test_implict_cast.groovy | 47 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index 51c8f5a257f..ccf00f701d1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -220,7 +220,8 @@ public class CastExpr extends Expr { return "CAST(" + getChild(0).toSql() + " AS " + type.toString() + ")"; } } else { - return "CAST(" + getChild(0).toSql() + " AS " + targetTypeDef.toSql() + ")"; + return "CAST(" + getChild(0).toSql() + " AS " + + (isImplicit ? type.toString() : targetTypeDef.toSql()) + ")"; } } diff --git a/regression-test/suites/correctness_p0/test_implict_cast.groovy b/regression-test/suites/correctness_p0/test_implict_cast.groovy index 1c870f66595..90763b1ca7a 100644 --- a/regression-test/suites/correctness_p0/test_implict_cast.groovy +++ b/regression-test/suites/correctness_p0/test_implict_cast.groovy @@ -56,4 +56,51 @@ suite("test_implict_cast") { sql """ drop table if exists cast_test_table; """ + + sql """drop table if exists test_orders_t""" + sql """drop table if exists test_servers_t""" + + sql """CREATE TABLE `test_orders_t` ( + `a1` date NOT NULL, + `a2` varchar(50) NOT NULL, + `a3` int(11) NULL, + `a4` int(11) NULL, + `a5` varchar(128) NULL, + `a6` int(11) NULL, + `a7` varchar(50) NULL, + `a8` DECIMAL(8, 2) NULL, + `a9` int(11) NULL + ) ENGINE=OLAP + UNIQUE KEY(`a1`, `a2`, `a3`) + DISTRIBUTED BY HASH(`a2`) BUCKETS 2 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + + sql """CREATE TABLE `test_servers_t` ( + `b1` bigint(20) NULL, + `b2` text NULL, + `b3` text NULL + ) ENGINE=OLAP + UNIQUE KEY(`b1`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`b1`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); """ + + sql """set enable_nereids_planner=false;""" + sql """SELECT a5 AS account_id + ,a4 AS a4 + ,CASE WHEN a7 = 'MC' THEN a8*0.034 + ELSE a8 END AS total_top_up + ,from_unixtime(cast(a9 AS BIGINT) - 5*3600) AS pay_date + FROM test_orders_t + WHERE a6 IN ( 2 , 5) + AND a4 IN ( SELECT b1 FROM test_servers_t WHERE b2 = 'yes' AND (b1 = 22101 or b3 = 'UTC-5')) + AND a9 >= 1672930800 + AND a1 = current_date();""" + + sql """drop table if exists test_orders_t""" + sql """drop table if exists test_servers_t""" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org