From 48024305ce30ba9db0481cca4b1d7b8973075610 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Mon, 13 May 2024 19:05:55 -0400 Subject: [PATCH 1/5] fix: resolve merge conflicts --- python/datafusion/tests/test_functions.py | 2 ++ src/functions.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/python/datafusion/tests/test_functions.py b/python/datafusion/tests/test_functions.py index d834f587f..e5e3b9660 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(22) == pa.array([True, False, False]) def test_hash_functions(df): diff --git a/src/functions.rs b/src/functions.rs index 4b137d90d..09a165a52 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -474,6 +474,7 @@ expr_fn!( ); expr_fn!(sqrt, num); expr_fn!(starts_with, arg1 arg2, "Returns true if string starts with prefix."); +expr_fn!(ends_with, arg1 arg2, "Returns true if string ends with suffix."); 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); From 2878f1616d889f9896670c7c69f8bd78ce3958a2 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Tue, 14 May 2024 11:30:02 -0400 Subject: [PATCH 2/5] fix: wrap pyfunction --- src/functions.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functions.rs b/src/functions.rs index 09a165a52..42c581ff2 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -708,6 +708,7 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(split_part))?; m.add_wrapped(wrap_pyfunction!(sqrt))?; m.add_wrapped(wrap_pyfunction!(starts_with))?; + m.add_wrapped(wrap_pyfunction!(ends_with))?; m.add_wrapped(wrap_pyfunction!(stddev))?; m.add_wrapped(wrap_pyfunction!(stddev_pop))?; m.add_wrapped(wrap_pyfunction!(stddev_samp))?; From 3cca70860ac60bc2f9c7d8f7e930d21dcad797a7 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Tue, 14 May 2024 11:31:39 -0400 Subject: [PATCH 3/5] fix: alphabetical ordering of function --- src/functions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.rs b/src/functions.rs index 42c581ff2..d6f5ff5bb 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -653,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))?; @@ -708,7 +709,6 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(split_part))?; m.add_wrapped(wrap_pyfunction!(sqrt))?; m.add_wrapped(wrap_pyfunction!(starts_with))?; - m.add_wrapped(wrap_pyfunction!(ends_with))?; m.add_wrapped(wrap_pyfunction!(stddev))?; m.add_wrapped(wrap_pyfunction!(stddev_pop))?; m.add_wrapped(wrap_pyfunction!(stddev_samp))?; From e5d577fdfa2f5a09080d12b2197cb6901b35f6c8 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Tue, 14 May 2024 11:50:48 -0400 Subject: [PATCH 4/5] refactor: update arg names --- src/functions.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index d6f5ff5bb..8a7d73839 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,8 +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!(ends_with, arg1 arg2, "Returns true if string ends with suffix."); +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); From ada9d18fe98341d4a601d76eb71a00bc01757188 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Tue, 14 May 2024 12:17:49 -0400 Subject: [PATCH 5/5] fix: assert correct column number --- python/datafusion/tests/test_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/datafusion/tests/test_functions.py b/python/datafusion/tests/test_functions.py index e5e3b9660..d2dafc199 100644 --- a/python/datafusion/tests/test_functions.py +++ b/python/datafusion/tests/test_functions.py @@ -574,7 +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(22) == pa.array([True, False, False]) + assert result.column(28) == pa.array([True, False, False]) def test_hash_functions(df):