Kev1n8 commented on code in PR #11955:
URL: https://github.com/apache/datafusion/pull/11955#discussion_r1714634441
##########
datafusion/functions/src/unicode/right.rs:
##########
@@ -83,6 +93,47 @@ impl ScalarUDFImpl for RightFunc {
/// right('abcde', 2) = 'de'
/// The implementation uses UTF-8 code points as characters
pub fn right<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
+ if args[0].data_type() == &DataType::Utf8View {
+ string_view_right(args)
+ } else {
+ string_right::<T>(args)
+ }
+}
+
+// Currently the return type can only be Utf8 or LargeUtf8, to reach fully
support, we need
+// to edit the `get_optimal_return_type` in utils.rs to make the udfs be able
to return Utf8View
+// See
https://github.com/apache/datafusion/issues/11790#issuecomment-2283777166
+fn string_view_right(args: &[ArrayRef]) -> Result<ArrayRef> {
+ let string_array = as_string_view_array(&args[0])?;
+ let n_array = as_int64_array(&args[1])?;
+
+ let result = string_array
Review Comment:
Thanks for the advice. I couldn't come up with a proper way to combine them
but now I get it :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]