Skip to content

Commit 1dff1fa

Browse files
committed
feat: add python bindings for ends_with function
1 parent d41eba4 commit 1dff1fa

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

datafusion/tests/test_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ def test_string_functions(df):
533533
f.translate(column("a"), literal("or"), literal("ld")),
534534
f.trim(column("c")),
535535
f.upper(column("c")),
536+
f.ends_with(column("a"), literal("llo")),
536537
)
537538
result = df.collect()
538539
assert len(result) == 1
@@ -573,6 +574,7 @@ def test_string_functions(df):
573574
assert result.column(25) == pa.array(["Helll", "Wldld", "!"])
574575
assert result.column(26) == pa.array(["hello", "world", "!"])
575576
assert result.column(27) == pa.array(["HELLO ", " WORLD ", " !"])
577+
assert result.column(22) == pa.array([True, False, False])
576578

577579

578580
def test_hash_functions(df):

src/functions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ expr_fn!(
466466
);
467467
scalar_function!(sqrt, Sqrt);
468468
expr_fn!(starts_with, arg1 arg2, "Returns true if string starts with prefix.");
469+
expr_fn!(ends_with, arg1 arg2, "Returns true if string ends with suffix.");
469470
scalar_function!(strpos, Strpos, "Returns starting index of specified substring within string, or zero if it's not present. (Same as position(substring in string), but note the reversed argument order.)");
470471
scalar_function!(substr, Substr);
471472
expr_fn!(tan, num);
@@ -701,6 +702,7 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
701702
m.add_wrapped(wrap_pyfunction!(split_part))?;
702703
m.add_wrapped(wrap_pyfunction!(sqrt))?;
703704
m.add_wrapped(wrap_pyfunction!(starts_with))?;
705+
m.add_wrapped(wrap_pyfunction!(ends_with))?;
704706
m.add_wrapped(wrap_pyfunction!(stddev))?;
705707
m.add_wrapped(wrap_pyfunction!(stddev_pop))?;
706708
m.add_wrapped(wrap_pyfunction!(stddev_samp))?;

0 commit comments

Comments
 (0)