Skip to content

Commit

Permalink
fix p0
Browse files Browse the repository at this point in the history
  • Loading branch information
LiBinfeng-01 committed Sep 30, 2024
1 parent 592ffc4 commit 0cad6bf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ public static Expression sqrt(DoubleLiteral first) {
*/
@ExecFunction(name = "power")
public static Expression power(DoubleLiteral first, DoubleLiteral second) {
checkInputBoundary(second, Double.MIN_VALUE, Double.MAX_VALUE, true, true);
checkInputBoundary(second, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, false);
return checkOutputBoundary(new DoubleLiteral(Math.pow(first.getValue(), second.getValue())));
}

Expand Down Expand Up @@ -890,7 +890,7 @@ public static Expression tan(DoubleLiteral first) {
*/
@ExecFunction(name = "asin")
public static Expression asin(DoubleLiteral first) {
checkInputBoundary(first, 1.0, 1.0, true, true);
checkInputBoundary(first, -1.0, 1.0, true, true);
return checkOutputBoundary(new DoubleLiteral(Math.asin(first.getValue())));
}

Expand All @@ -899,7 +899,7 @@ public static Expression asin(DoubleLiteral first) {
*/
@ExecFunction(name = "acos")
public static Expression acos(DoubleLiteral first) {
checkInputBoundary(first, 1.0, 1.0, true, true);
checkInputBoundary(first, -1.0, 1.0, true, true);
return checkOutputBoundary(new DoubleLiteral(Math.acos(first.getValue())));
}

Expand Down
4 changes: 0 additions & 4 deletions regression-test/data/datatype_p0/double/test_double_nan.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
1 \N

-- !select --
\N

4 changes: 0 additions & 4 deletions regression-test/data/datatype_p0/float/test_float_nan.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
1 \N

-- !select --
\N

13 changes: 10 additions & 3 deletions regression-test/suites/datatype_p0/double/test_double_nan.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ suite("test_double_nan", "datatype_p0") {
def tableName = "tbl_test_double_nan"
sql "DROP TABLE IF EXISTS ${tableName}"
sql "CREATE TABLE if NOT EXISTS ${tableName} (k int, value double) DUPLICATE KEY(k) DISTRIBUTED BY HASH (k) BUCKETS 1 PROPERTIES ('replication_num' = '1');"
sql """insert into ${tableName} select 1, sqrt(-1);"""

test {
sql """insert into ${tableName} select 1, sqrt(-1);"""
exception "errCode"
}

qt_select "select * from ${tableName} order by 1;"
qt_select "select sqrt(-1);"
test {
sql "select sqrt(-1);"
exception "errCode"
}

sql "DROP TABLE IF EXISTS ${tableName}"
}
}
12 changes: 9 additions & 3 deletions regression-test/suites/datatype_p0/float/test_float_nan.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ suite("test_float_nan", "datatype_p0") {
def tableName = "tbl_test_float_nan"
sql "DROP TABLE IF EXISTS ${tableName}"
sql "CREATE TABLE if NOT EXISTS ${tableName} (k int, value float) DUPLICATE KEY(k) DISTRIBUTED BY HASH (k) BUCKETS 1 PROPERTIES ('replication_num' = '1');"
sql """insert into ${tableName} select 1, sqrt(-1);"""
test {
sql """insert into ${tableName} select 1, sqrt(-1);"""
exception "errCode"
}

qt_select "select * from ${tableName} order by 1;"
qt_select "select sqrt(-1);"
test {
sql "select sqrt(-1);"
exception "errCode"
}

sql "DROP TABLE IF EXISTS ${tableName}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ suite("nereids_scalar_fn_A") {
qt_sql_abs_DecimalV2_notnull "select abs(kdcmls1) from fn_test_not_nullable order by kdcmls1"
qt_sql_acos_Double "select acos(kdbl) from fn_test order by kdbl"
qt_sql_acos_Double_notnull "select acos(kdbl) from fn_test_not_nullable order by kdbl"
qt_sql_acos_Double_NAN "select acos(cast(1.1 as double))"
test {
sql "select acos(cast(1.1 as double))"
exception "errCode"
}
qt_sql_acos_Double_NULL "select acos(null)"
sql "select aes_decrypt(kvchrs1, kvchrs1) from fn_test order by kvchrs1, kvchrs1"
sql "select aes_decrypt(kvchrs1, kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ suite("fold_constant_numeric_arithmatic") {

testFoldConst("SELECT truncate(123.456, -1)")
// testFoldConst("select pmod(-9223372036854775808,-1)")
testFoldConst("select sqrt(-1)")
//Coalesce function cases
testFoldConst("SELECT COALESCE(NULL, 5) AS coalesce_case_1")
testFoldConst("SELECT COALESCE(NULL, NULL, 7) AS coalesce_case_2")
Expand Down Expand Up @@ -211,8 +210,6 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT SQRT(16) AS sqrt_case_1") //sqrt(16) = 4
testFoldConst("SELECT SQRT(0) AS sqrt_case_2") //sqrt(0) = 0
testFoldConst("SELECT SQRT(2) AS sqrt_case_3") //sqrt(2)
//Exception: Sqrt of negative values (undefined)
testFoldConst("SELECT SQRT(-1) AS sqrt_case_exception") //undefined (returns NULL or error)

//Power function cases
testFoldConst("SELECT POWER(2, 3) AS power_case_1") //2^3 = 8
Expand Down Expand Up @@ -326,8 +323,6 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT SQRT(16.0) AS dsqrt_case_1") //sqrt(16.0) = 4
testFoldConst("SELECT SQRT(0.0) AS dsqrt_case_2") //sqrt(0.0) = 0
testFoldConst("SELECT SQRT(2.0) AS dsqrt_case_3") //sqrt(2.0)
//Exception: Sqrt of negative values
testFoldConst("SELECT SQRT(-1.0) AS dsqrt_case_exception") //undefined (returns NULL or error)

//Fmod function cases (floating-point modulus)
testFoldConst("SELECT MOD(10.5, 3.2) AS fmod_case_1") //fmod(10.5 % 3.2)
Expand Down Expand Up @@ -410,9 +405,6 @@ test {
testFoldConst("SELECT COS(1E308) AS cos_large_value") //Cos overflow
testFoldConst("SELECT TAN(PI() / 2) AS tan_undefined") //Undefined for tan(π/2)

//Sqrt, Ln, and other operations with negative or zero edge cases
testFoldConst("SELECT SQRT(-1) AS sqrt_invalid_value") //Sqrt of negative number (undefined)

//Miscellaneous operations like bit manipulations and modulo on edge cases
testFoldConst("SELECT BIN(-1) AS bin_negative_value") //Bin of negative number (may be undefined)
testFoldConst("SELECT BIT_COUNT(-1) AS bitcount_negative_value") //BitCount of negative number
Expand Down

0 comments on commit 0cad6bf

Please sign in to comment.