MCPcopy Create free account
hub / github.com/apache/datafusion / btrim

Function btrim

datafusion/functions/src/string/btrim.rs:34–43  ·  view source on GitHub ↗

Returns the longest string with leading and trailing characters removed. If the characters are not specified, spaces are removed. btrim('xyxtrimyyx', 'xyz') = 'trim'

(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

32/// Returns the longest string with leading and trailing characters removed. If the characters are not specified, spaces are removed.
33/// btrim('xyxtrimyyx', 'xyz') = 'trim'
34fn btrim<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
35 let use_string_view = args[0].data_type() == &DataType::Utf8View;
36 let args = if args.len() > 1 {
37 let arg1 = arrow::compute::kernels::cast::cast(&args[1], args[0].data_type())?;
38 vec![Arc::clone(&args[0]), arg1]
39 } else {
40 args.to_owned()
41 };
42 general_trim::<T, TrimBoth>(&args, use_string_view)
43}
44
45#[user_doc(
46 doc_section(label = "String Functions"),

Callers 6

runFunction · 0.85
build_test_data_frameFunction · 0.85
test_fn_btrimFunction · 0.85
test_fn_btrim_with_charsFunction · 0.85
criterion_benchmarkFunction · 0.85
trimFunction · 0.85

Calls 3

castFunction · 0.50
data_typeMethod · 0.45
lenMethod · 0.45

Tested by 2

test_fn_btrimFunction · 0.68
test_fn_btrim_with_charsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…