Skip to content

Commit

Permalink
add optimized_utf8_to_str_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev1n8 committed Aug 18, 2024
1 parent 48e1643 commit 6ff32fc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions datafusion/functions/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ macro_rules! get_optimal_return_type {
// `utf8_to_str_type`: returns either a Utf8 or LargeUtf8 based on the input type size.
get_optimal_return_type!(utf8_to_str_type, DataType::LargeUtf8, DataType::Utf8);

// `optimized_utf8_to_str_type`: returns Utf8View when the string function has a specialised
// implementation for StringView which returns Utf8View.
pub(crate) fn optimized_utf8_to_str_type(
arg_type: &DataType,
name: &str,
) -> Result<DataType> {
let support_list = ["substr"];
if support_list.contains(&name) {
Ok(DataType::Utf8View)
} else {
utf8_to_str_type(arg_type, name)
}
}

// `utf8_to_int_type`: returns either a Int32 or Int64 based on the input type size.
get_optimal_return_type!(utf8_to_int_type, DataType::Int64, DataType::Int32);

Expand Down

0 comments on commit 6ff32fc

Please sign in to comment.