Skip to content

Commit a05f388

Browse files
committed
add Binary String Functions
1 parent b4d383b commit a05f388

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

datafusion/tests/test_functions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,13 @@ def test_case(df):
467467
assert result.column(0) == pa.array([10, 8, 8])
468468
assert result.column(1) == pa.array(["Hola", "Mundo", "!!"])
469469
assert result.column(2) == pa.array(["Hola", "Mundo", None])
470+
471+
472+
def test_binary_string_functions(df):
473+
df = df.select(
474+
f.encode(column("a"), literal("base64")),
475+
)
476+
result = df.collect()
477+
assert len(result) == 1
478+
result = result[0]
479+
assert result.column(0) == pa.array(["SGVsbG8", "V29ybGQ", "IQ"])

src/functions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ scalar_function!(uuid, Uuid);
329329
scalar_function!(r#struct, Struct); // Use raw identifier since struct is a keyword
330330
scalar_function!(from_unixtime, FromUnixtime);
331331
scalar_function!(arrow_typeof, ArrowTypeof);
332+
332333
scalar_function!(random, Random);
334+
//Binary String Functions
335+
scalar_function!(encode, Encode);
336+
scalar_function!(decode, Decode);
333337

334338
aggregate_function!(approx_distinct, ApproxDistinct);
335339
aggregate_function!(approx_median, ApproxMedian);
@@ -482,5 +486,9 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
482486
m.add_wrapped(wrap_pyfunction!(var_pop))?;
483487
m.add_wrapped(wrap_pyfunction!(var_samp))?;
484488
m.add_wrapped(wrap_pyfunction!(window))?;
489+
490+
//Binary String Functions
491+
m.add_wrapped(wrap_pyfunction!(encode))?;
492+
m.add_wrapped(wrap_pyfunction!(decode))?;
485493
Ok(())
486494
}

0 commit comments

Comments
 (0)