Kev1n8 commented on PR #11955:
URL: https://github.com/apache/datafusion/pull/11955#issuecomment-2284463629

   Pasting a possible implementation of `StringViewArray` output here (current 
implementation returns `StringArray`):
   ```
   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 mut builder = StringViewBuilder::new();
       let combined = string_array.iter().zip(n_array);
   
       for iter in combined {
           if let (Some(str), Some(n)) = iter {
               match n.cmp(&0) {
                   Ordering::Less => {
                       let start = n.unsigned_abs() as usize;
                       let sub_string = &str[start..];
                       builder.append_value(sub_string);
                   }
                   Ordering::Equal => {
                       builder.append_null();
                   }
                   Ordering::Greater => {
                       let start = max(str.chars().count() as i64 - n, 0) as 
usize;
                       let sub_string = &str[start..];
                       builder.append_value(sub_string);
                   }
               }
           } else {
               builder.append_null();
           }
       }
       let result = builder.finish();
       Ok(Arc::new(result) as ArrayRef)
   }
   ```


-- 
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]

Reply via email to