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 124ed589d4..9122f0f4ad 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 @@ -81,6 +81,8 @@ public class Cast extends Expression implements UnaryExpression { return true; } else if (childDataType.isJsonType() || targetType.isJsonType()) { return true; + } else if (childDataType.isVariantType() || targetType.isVariantType()) { + 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 2fe4d53eb8..dae669e296 100644 --- a/regression-test/suites/query_p0/cast/test_cast.groovy +++ b/regression-test/suites/query_p0/cast/test_cast.groovy @@ -150,7 +150,8 @@ suite('test_cast', "arrow_flight_sql") { sql """ CREATE TABLE IF NOT EXISTS test_json ( id INT not null, - j JSON not null + j JSON not null, + v variant not null ) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 10 @@ -158,9 +159,10 @@ suite('test_cast', "arrow_flight_sql") { """ sql """ - INSERT INTO test_json VALUES(26, '{"k1":"v1", "k2": 200}'); + INSERT INTO test_json VALUES(26, '{"k1":"v1", "k2": 200}', '[\"asd]'); """ sql "sync" sql "Select cast(j as int) from test_json" + sql "select cast(v as int) from test_json" sql "DROP TABLE IF EXISTS test_json" }