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) cast from json should always nullable #34707

Merged
merged 1 commit into from
May 13, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}