Skip to content

Commit cd9a04a

Browse files
committed
Add arrow_typeof function
1 parent 76ecf56 commit cd9a04a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

datafusion/tests/test_functions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,19 @@ def test_binary_string_functions(df):
760760
assert pa.array(result.column(1)).cast(pa.string()) == pa.array(
761761
["Hello", "World", "!"]
762762
)
763+
764+
765+
def test_other_functions(df):
766+
test_items = [
767+
[
768+
f.arrow_typeof(column("b").cast(pa.int32())),
769+
lambda: [pa.int32()] * 3,
770+
]
771+
]
772+
773+
for stmt, py_expr in test_items:
774+
query_result = df.select(stmt).collect()[0].column(0)
775+
for a, b in zip(query_result, py_expr()):
776+
np.testing.assert_array_almost_equal(
777+
np.array(a.as_py(), dtype=float), np.array(b, dtype=float)
778+
)

src/functions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ scalar_function!(array_slice, ArraySlice);
446446
scalar_function!(list_slice, ArraySlice);
447447
scalar_function!(flatten, Flatten);
448448

449+
// Other Functions
450+
scalar_function!(arrow_typeof, ArrowTypeof);
451+
449452
aggregate_function!(approx_distinct, ApproxDistinct);
450453
aggregate_function!(approx_median, ApproxMedian);
451454
aggregate_function!(approx_percentile_cont, ApproxPercentileCont);
@@ -689,5 +692,8 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
689692
m.add_wrapped(wrap_pyfunction!(list_slice))?;
690693
m.add_wrapped(wrap_pyfunction!(flatten))?;
691694

695+
// Other Functions
696+
m.add_wrapped(wrap_pyfunction!(arrow_typeof))?;
697+
692698
Ok(())
693699
}

0 commit comments

Comments
 (0)