Jefffrey commented on code in PR #23880:
URL: https://github.com/apache/datafusion/pull/23880#discussion_r3662030627
##########
datafusion/spark/src/function/string/quote.rs:
##########
@@ -88,34 +89,62 @@ fn spark_quote_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
fn quote_array<T: OffsetSizeTrait>(array: &ArrayRef) -> Result<ArrayRef> {
let str_array = as_generic_string_array::<T>(array)?;
- let result = str_array
- .iter()
- .map(|s| s.map(compute_quote))
- .collect::<StringArray>();
- Ok(Arc::new(result))
+ // Slicing an array keeps the whole value buffer and narrows only the
+ // offsets, so measure the data through the offsets rather than through
+ // `value_data()`.
+ let offsets = str_array.value_offsets();
+ let data_len = match (offsets.first(), offsets.last()) {
+ (Some(first), Some(last)) => last.as_usize() - first.as_usize(),
+ _ => 0,
+ };
Review Comment:
offset buffers are guaranteed to be non-empty so we can unwrap instead of
matching here
--
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]