diff --git a/datafusion/functions/src/string/common.rs b/datafusion/functions/src/string/common.rs index 3770fd5b96de..2585822d14ba 100644 --- a/datafusion/functions/src/string/common.rs +++ b/datafusion/functions/src/string/common.rs @@ -35,8 +35,7 @@ use datafusion_expr::ColumnarValue; /// Make a `u128` based on the given substr, start(offset to view.offset), and /// push into to the given buffers -// TODO: tmp copy, remove after #12383 is merged -fn make_and_append_view( +pub(crate) fn make_and_append_view( views_buffer: &mut Vec, null_builder: &mut NullBufferBuilder, raw: &u128, diff --git a/datafusion/functions/src/unicode/substr.rs b/datafusion/functions/src/unicode/substr.rs index 1833971603ce..8376b15a13f4 100644 --- a/datafusion/functions/src/unicode/substr.rs +++ b/datafusion/functions/src/unicode/substr.rs @@ -19,10 +19,11 @@ use std::any::Any; use std::cmp::max; use std::sync::Arc; +use crate::string::common::make_and_append_view; use crate::utils::{make_scalar_function, utf8_to_str_type}; use arrow::array::{ - make_view, Array, ArrayAccessor, ArrayIter, ArrayRef, AsArray, ByteView, - GenericStringArray, OffsetSizeTrait, StringViewArray, + Array, ArrayAccessor, ArrayIter, ArrayRef, AsArray, GenericStringArray, + OffsetSizeTrait, StringViewArray, }; use arrow::datatypes::DataType; use arrow_buffer::{NullBufferBuilder, ScalarBuffer}; @@ -165,27 +166,6 @@ fn get_true_start_end(input: &str, start: i64, count: Option) -> (usize, us (st, ed) } -/// Make a `u128` based on the given substr, start(offset to view.offset), and -/// push into to the given buffers -pub fn make_and_append_view( - views_buffer: &mut Vec, - null_builder: &mut NullBufferBuilder, - raw: &u128, - substr: &str, - start: u32, -) { - let substr_len = substr.len(); - let sub_view = if substr_len > 12 { - let view = ByteView::from(*raw); - make_view(substr.as_bytes(), view.buffer_index, view.offset + start) - } else { - // inline value does not need block id or offset - make_view(substr.as_bytes(), 0, 0) - }; - views_buffer.push(sub_view); - null_builder.append_non_null(); -} - // The decoding process refs the trait at: arrow/arrow-data/src/byte_view.rs:44 // From for ByteView fn string_view_substr(