Skip to content

Commit 6c8f8c6

Browse files
committed
Add isnan and iszero
1 parent d48c610 commit 6c8f8c6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

datafusion/tests/test_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def test_math_functions():
131131
f.sinh(col_v),
132132
f.tanh(col_v),
133133
f.factorial(literal(6)),
134+
f.isnan(col_nav),
135+
f.iszero(col_nav),
134136
)
135137
batches = df.collect()
136138
assert len(batches) == 1
@@ -185,6 +187,8 @@ def test_math_functions():
185187
np.testing.assert_array_almost_equal(result.column(32), np.sinh(values))
186188
np.testing.assert_array_almost_equal(result.column(33), np.tanh(values))
187189
np.testing.assert_array_almost_equal(result.column(34), math.factorial(6))
190+
np.testing.assert_array_almost_equal(result.column(35), np.isnan(na_values))
191+
np.testing.assert_array_almost_equal(result.column(36), na_values == 0)
188192

189193

190194
def test_string_functions(df):

src/functions.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ scalar_function!(factorial, Factorial);
230230
scalar_function!(floor, Floor);
231231
scalar_function!(gcd, Gcd);
232232
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.");
233-
scalar_function!(lcm, Lcm);
233+
scalar_function!(isnan, Isnan);
234+
scalar_function!(iszero, Iszero);scalar_function!(lcm, Lcm);
234235
scalar_function!(left, Left, "Returns first n characters in the string, or when n is negative, returns all but last |n| characters.");
235236
scalar_function!(ln, Ln);
236237
scalar_function!(log, Log);
@@ -414,6 +415,8 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
414415
m.add_wrapped(wrap_pyfunction!(grouping))?;
415416
m.add_wrapped(wrap_pyfunction!(in_list))?;
416417
m.add_wrapped(wrap_pyfunction!(initcap))?;
418+
m.add_wrapped(wrap_pyfunction!(isnan))?;
419+
m.add_wrapped(wrap_pyfunction!(iszero))?;
417420
m.add_wrapped(wrap_pyfunction!(lcm))?;
418421
m.add_wrapped(wrap_pyfunction!(left))?;
419422
m.add_wrapped(wrap_pyfunction!(length))?;

0 commit comments

Comments
 (0)