Omega359 commented on PR #12027:
URL: https://github.com/apache/datafusion/pull/12027#issuecomment-2294319110

   I believe I've actually come up with a better way of handling the different 
string types for ArrayRef's that I think will be generally more useful than the 
`StringArrayType` (though I don't know if we would want to remove it 
completely). Here's an example for the substr_index udf:
   
   ```Rust
   fn substr_index(args: &[ArrayRef]) -> Result<ArrayRef> {
       let string_array: StringArrays = StringArrays::try_from(&args[0])?;
       let delimiter_array: StringArrays = StringArrays::try_from(&args[1])?;
       let count_array: &PrimitiveArray<Int64Type> = args[2].as_primitive();
       substr_index_general::<Int32Type, _, _>(string_array, delimiter_array, 
count_array)
   }
   
   pub fn substr_index_general<
       'a,
       T: ArrowPrimitiveType,
       V: ArrayAccessor<Item = &'a str>,
       P: ArrayAccessor<Item = i64>,
   >(
       string_array: V,
       delimiter_array: V,
       count_array: P,
   ) -> Result<ArrayRef>
   where
       T::Native: OffsetSizeTrait,
   {
       let mut builder = StringBuilder::new();
       let string_iter = ArrayIter::new(string_array);
   ...
   }
   
   StringArrays is an Enum that implements a variety of types including 
TryFrom, From, Array, ArrayAccessor, and, well, StringArrayType. 
   
   I came up with this approach because I was unable and/or unhappy with the 
current approaches as I was refactoring the to_timestamp udf to directly 
support ingesting Utf8View arrays.


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to