my-vegetable-has-exploded commented on code in PR #8268:
URL: https://github.com/apache/arrow-datafusion/pull/8268#discussion_r1409296319
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -1991,6 +1992,71 @@ pub fn array_intersect(args: &[ArrayRef]) ->
Result<ArrayRef> {
}
}
+pub fn general_array_distinct<OffsetSize: OffsetSizeTrait>(
+ array: &GenericListArray<OffsetSize>,
+ field: &FieldRef,
+) -> Result<ArrayRef> {
+ let dt = array.value_type();
+ let mut offsets = vec![OffsetSize::usize_as(0)];
+ let mut new_arrays = vec![];
+ let converter = RowConverter::new(vec![SortField::new(dt.clone())])?;
+ // distinct for each list in ListArray
+ for arr in array.iter().flatten() {
+ let values = converter.convert_columns(&[arr])?;
+ let mut rows = Vec::with_capacity(values.num_rows());
+ // sort elements in list and remove duplicates
+ for val in values.iter().sorted().dedup() {
+ rows.push(val);
+ }
Review Comment:
Thanks, 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]