This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit c71d0b6b223d092d98bc42b3b81f3d5636e9e63e Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Mon May 13 14:42:04 2024 +0800 [fix](Nereids) cast from json should always nullable (#34707) --- .../apache/doris/nereids/trees/expressions/Cast.java | 2 ++ regression-test/suites/query_p0/cast/test_cast.groovy | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java index 76cb1826e55..62bd3639b5a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java @@ -79,6 +79,8 @@ public class Cast extends Expression implements UnaryExpression { return true; } else if (!childDataType.isTimeLikeType() && targetType.isTimeLikeType()) { return true; + } else if (childDataType.isJsonType()) { + return true; } else { return child().nullable(); } diff --git a/regression-test/suites/query_p0/cast/test_cast.groovy b/regression-test/suites/query_p0/cast/test_cast.groovy index c0df52b39e7..2fe4d53eb80 100644 --- a/regression-test/suites/query_p0/cast/test_cast.groovy +++ b/regression-test/suites/query_p0/cast/test_cast.groovy @@ -145,4 +145,22 @@ suite('test_cast', "arrow_flight_sql") { sql "select * from ${tbl} where case when k0 = 101 then 'true' else 1 end" result([[101]]) } + + sql "DROP TABLE IF EXISTS test_json" + sql """ + CREATE TABLE IF NOT EXISTS test_json ( + id INT not null, + j JSON not null + ) + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 10 + PROPERTIES("replication_num" = "1"); + """ + + sql """ + INSERT INTO test_json VALUES(26, '{"k1":"v1", "k2": 200}'); + """ + sql "sync" + sql "Select cast(j as int) from test_json" + sql "DROP TABLE IF EXISTS test_json" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org