Dandandan commented on code in PR #20364:
URL: https://github.com/apache/datafusion/pull/20364#discussion_r2809091594
##########
datafusion/functions-nested/src/set_ops.rs:
##########
@@ -527,42 +531,52 @@ fn general_array_distinct<OffsetSize: OffsetSizeTrait>(
if array.is_empty() {
return Ok(Arc::new(array.clone()) as ArrayRef);
}
+ let value_offsets = array.value_offsets();
let dt = array.value_type();
- let mut offsets = Vec::with_capacity(array.len());
+ let mut offsets = Vec::with_capacity(array.len() + 1);
offsets.push(OffsetSize::usize_as(0));
- let mut new_arrays = Vec::with_capacity(array.len());
- let converter = RowConverter::new(vec![SortField::new(dt)])?;
- // distinct for each list in ListArray
- for arr in array.iter() {
- let last_offset: OffsetSize = offsets.last().copied().unwrap();
- let Some(arr) = arr else {
- // Add same offset for null
+
+ // Convert all values to row format in a single batch for performance
+ let converter = RowConverter::new(vec![SortField::new(dt.clone())])?;
+ let rows = converter.convert_columns(&[Arc::clone(array.values())])?;
Review Comment:
I think as a follow-up, it might reuse the `Rows` and `HashSet` allocations
between batches.
--
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]