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/datafusion-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 344ebad  feat: add python bindings for ends_with function (#693)
344ebad is described below

commit 344ebad1989d6e7c14c63be63dd7132aadbea710
Author: Richard Tia <[email protected]>
AuthorDate: Tue May 14 22:33:11 2024 -0400

    feat: add python bindings for ends_with function (#693)
    
    * fix: resolve merge conflicts
    
    * fix: wrap pyfunction
    
    * fix: alphabetical ordering of function
    
    * refactor: update arg names
    
    * fix: assert correct column number
---
 python/datafusion/tests/test_functions.py | 2 ++
 src/functions.rs                          | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/python/datafusion/tests/test_functions.py 
b/python/datafusion/tests/test_functions.py
index d834f58..d2dafc1 100644
--- a/python/datafusion/tests/test_functions.py
+++ b/python/datafusion/tests/test_functions.py
@@ -533,6 +533,7 @@ def test_string_functions(df):
         f.translate(column("a"), literal("or"), literal("ld")),
         f.trim(column("c")),
         f.upper(column("c")),
+        f.ends_with(column("a"), literal("llo")),
     )
     result = df.collect()
     assert len(result) == 1
@@ -573,6 +574,7 @@ def test_string_functions(df):
     assert result.column(25) == pa.array(["Helll", "Wldld", "!"])
     assert result.column(26) == pa.array(["hello", "world", "!"])
     assert result.column(27) == pa.array(["HELLO ", " WORLD ", " !"])
+    assert result.column(28) == pa.array([True, False, False])
 
 
 def test_hash_functions(df):
diff --git a/src/functions.rs b/src/functions.rs
index 4b137d9..8a7d738 100644
--- a/src/functions.rs
+++ b/src/functions.rs
@@ -407,6 +407,7 @@ expr_fn!(cosh, num);
 expr_fn!(degrees, num);
 expr_fn!(decode, input encoding);
 expr_fn!(encode, input encoding);
+expr_fn!(ends_with, string suffix, "Returns true if string ends with suffix.");
 expr_fn!(exp, num);
 expr_fn!(factorial, num);
 expr_fn!(floor, num);
@@ -473,7 +474,7 @@ expr_fn!(
     "Splits string at occurrences of delimiter and returns the n'th field 
(counting from one)."
 );
 expr_fn!(sqrt, num);
-expr_fn!(starts_with, arg1 arg2, "Returns true if string starts with prefix.");
+expr_fn!(starts_with, string prefix, "Returns true if string starts with 
prefix.");
 expr_fn!(strpos, string substring, "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.)");
 expr_fn!(substr, string position);
 expr_fn!(tan, num);
@@ -652,6 +653,7 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
     m.add_wrapped(wrap_pyfunction!(datetrunc))?;
     m.add_wrapped(wrap_pyfunction!(date_trunc))?;
     m.add_wrapped(wrap_pyfunction!(digest))?;
+    m.add_wrapped(wrap_pyfunction!(ends_with))?;
     m.add_wrapped(wrap_pyfunction!(exp))?;
     m.add_wrapped(wrap_pyfunction!(factorial))?;
     m.add_wrapped(wrap_pyfunction!(floor))?;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to