From 6022cba5f7ba95d4c84e29c7152bcf5cf78b424c Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Thu, 7 Sep 2023 13:50:56 -0700 Subject: [PATCH 1/4] Add isnan --- datafusion/tests/test_functions.py | 2 ++ src/functions.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/datafusion/tests/test_functions.py b/datafusion/tests/test_functions.py index 1727e7e5..1a0133f2 100644 --- a/datafusion/tests/test_functions.py +++ b/datafusion/tests/test_functions.py @@ -131,6 +131,7 @@ def test_math_functions(): f.sinh(col_v), f.tanh(col_v), f.factorial(literal(6)), + f.isnan(col_nav), ) batches = df.collect() assert len(batches) == 1 @@ -185,6 +186,7 @@ def test_math_functions(): np.testing.assert_array_almost_equal(result.column(32), np.sinh(values)) np.testing.assert_array_almost_equal(result.column(33), np.tanh(values)) np.testing.assert_array_almost_equal(result.column(34), math.factorial(6)) + np.testing.assert_array_almost_equal(result.column(35), np.isnan(na_values)) def test_string_functions(df): diff --git a/src/functions.rs b/src/functions.rs index 6037ce19..d59b0039 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -230,6 +230,7 @@ scalar_function!(factorial, Factorial); scalar_function!(floor, Floor); scalar_function!(gcd, Gcd); scalar_function!(initcap, InitCap, "Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters."); +scalar_function!(isnan, IsNaN, "Returns true if a given number is +NaN or -NaN otherwise returns false."); scalar_function!(lcm, Lcm); scalar_function!(left, Left, "Returns first n characters in the string, or when n is negative, returns all but last |n| characters."); scalar_function!(ln, Ln); From cbc2bbc0a5c4deccc767e0ddef4a0d2dbef44d24 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Fri, 8 Sep 2023 09:25:34 -0700 Subject: [PATCH 2/4] Fix function description --- src/functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.rs b/src/functions.rs index d59b0039..07d51bc6 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -248,7 +248,7 @@ scalar_function!( scalar_function!( nanvl, Nanvl, - "Computes the MD5 hash of the argument, with the result written in hexadecimal." + "Returns x if x is not NaN otherwise returns y." ); scalar_function!(octet_length, OctetLength, "Returns number of bytes in the string. Since this version of the function accepts type character directly, it will not strip trailing spaces."); scalar_function!(pi, Pi); From fe24072ba9a9d300155b961660646f80c27916cb Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Fri, 8 Sep 2023 09:27:45 -0700 Subject: [PATCH 3/4] Fix format --- src/functions.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/functions.rs b/src/functions.rs index 07d51bc6..c7f9f9e2 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -230,7 +230,11 @@ scalar_function!(factorial, Factorial); scalar_function!(floor, Floor); scalar_function!(gcd, Gcd); scalar_function!(initcap, InitCap, "Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters."); -scalar_function!(isnan, IsNaN, "Returns true if a given number is +NaN or -NaN otherwise returns false."); +scalar_function!( + isnan, + IsNaN, + "Returns true if a given number is +NaN or -NaN otherwise returns false." +); scalar_function!(lcm, Lcm); scalar_function!(left, Left, "Returns first n characters in the string, or when n is negative, returns all but last |n| characters."); scalar_function!(ln, Ln); From 93fec0a65e8d203c572e54ca955306d0ba98e5c5 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Fri, 8 Sep 2023 09:39:00 -0700 Subject: [PATCH 4/4] Fix function name --- src/functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.rs b/src/functions.rs index c7f9f9e2..80a2dffc 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -232,7 +232,7 @@ scalar_function!(gcd, Gcd); scalar_function!(initcap, InitCap, "Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters."); scalar_function!( isnan, - IsNaN, + Isnan, "Returns true if a given number is +NaN or -NaN otherwise returns false." ); scalar_function!(lcm, Lcm);