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

[common] Fix overflow problem of NumericToBooleanCastRule #4519

Merged
merged 1 commit into from
Nov 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ private NumericToBooleanCastRule() {

@Override
public CastExecutor<Number, Boolean> create(DataType inputType, DataType targetType) {
return value -> value.intValue() != 0;
return value -> value.longValue() != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ public void testModifyColumnTypeFromNumericToDecimal() {
public void testModifyColumnTypeBooleanAndNumeric() {
// boolean To numeric and numeric To boolean
sql("CREATE TABLE T (a BOOLEAN, b BOOLEAN, c TINYINT, d INT, e BIGINT, f DOUBLE)");
sql("INSERT INTO T VALUES(true, false, cast(0 as TINYINT), 1 , 123, 3.14)");
sql(
"INSERT INTO T VALUES(true, false, cast(0 as TINYINT), 1 , -9223372036854775808, 3.14)");

sql("ALTER TABLE T MODIFY (a TINYINT, b INT, c BOOLEAN, d BOOLEAN, e BOOLEAN)");
List<Row> result = sql("SHOW CREATE TABLE T");
Expand Down
Loading