Skip to content

Commit

Permalink
[fix](Nereids) cast from json should always nullable (#34707)
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow committed May 13, 2024
1 parent 141c333 commit 97a10d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public boolean nullable() {
return true;
} else if (!childDataType.isTimeLikeType() && targetType.isTimeLikeType()) {
return true;
} else if (childDataType.isJsonType()) {
return true;
} else {
return child().nullable();
}
Expand Down
18 changes: 18 additions & 0 deletions regression-test/suites/query_p0/cast/test_cast.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 97a10d2

Please sign in to comment.