This is an automated email from the ASF dual-hosted git repository.

agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion-python.git


The following commit(s) were added to refs/heads/main by this push:
     new beabf26  Add `isnan` and `iszero` (#495)
beabf26 is described below

commit beabf2601038747e5b1a813114d6b22be83bf291
Author: Judah Rand <[email protected]>
AuthorDate: Tue Sep 12 15:20:11 2023 +0100

    Add `isnan` and `iszero` (#495)
    
    * Add `isnan` and `iszero`
    
    * Add test for `log`
    
    * Add missing newline!
    
    Co-authored-by: Liang-Chi Hsieh <[email protected]>
    
    * Fix linting
    
    ---------
    
    Co-authored-by: Liang-Chi Hsieh <[email protected]>
---
 datafusion/tests/test_functions.py | 10 ++++++++++
 src/functions.rs                   |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/datafusion/tests/test_functions.py 
b/datafusion/tests/test_functions.py
index 1727e7e..80795bf 100644
--- a/datafusion/tests/test_functions.py
+++ b/datafusion/tests/test_functions.py
@@ -131,6 +131,9 @@ def test_math_functions():
         f.sinh(col_v),
         f.tanh(col_v),
         f.factorial(literal(6)),
+        f.isnan(col_nav),
+        f.iszero(col_nav),
+        f.log(literal(3), col_v + literal(pa.scalar(1))),
     )
     batches = df.collect()
     assert len(batches) == 1
@@ -185,6 +188,13 @@ 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)
+    )
+    np.testing.assert_array_almost_equal(result.column(36), na_values == 0)
+    np.testing.assert_array_almost_equal(
+        result.column(37), np.emath.logn(3, values + 1.0)
+    )
 
 
 def test_string_functions(df):
diff --git a/src/functions.rs b/src/functions.rs
index d9a7d60..79cc19b 100644
--- a/src/functions.rs
+++ b/src/functions.rs
@@ -230,6 +230,8 @@ 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);
+scalar_function!(iszero, Iszero);
 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);
@@ -414,6 +416,8 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
     m.add_wrapped(wrap_pyfunction!(grouping))?;
     m.add_wrapped(wrap_pyfunction!(in_list))?;
     m.add_wrapped(wrap_pyfunction!(initcap))?;
+    m.add_wrapped(wrap_pyfunction!(isnan))?;
+    m.add_wrapped(wrap_pyfunction!(iszero))?;
     m.add_wrapped(wrap_pyfunction!(lcm))?;
     m.add_wrapped(wrap_pyfunction!(left))?;
     m.add_wrapped(wrap_pyfunction!(length))?;

Reply via email to