Skip to content

feat: add python bindings for ends_with function #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/datafusion/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))?;
Expand Down