joroKr21 commented on code in PR #15544: URL: https://github.com/apache/datafusion/pull/15544#discussion_r2026366689
########## datafusion/functions-aggregate/src/array_agg.rs: ########## @@ -500,11 +548,30 @@ impl Accumulator for OrderSensitiveArrayAggAccumulator { return Ok(()); } - let n_row = values[0].len(); - for index in 0..n_row { - let row = get_row_at_idx(values, index)?; - self.values.push(row[0].clone()); - self.ordering_values.push(row[1..].to_vec()); + let val = &values[0]; + let ord = &values[1..]; + let nulls = if self.ignore_nulls { + val.logical_nulls() + } else { + None + }; + + match nulls { + Some(nulls) if nulls.null_count() >= val.len() => (), + Some(nulls) => { + for i in 0..val.len() { + if nulls.is_valid(i) { + self.values.push(ScalarValue::try_from_array(val, i)?); + self.ordering_values.push(get_row_at_idx(ord, i)?) + } + } + } + None => { + for i in 0..val.len() { + self.values.push(ScalarValue::try_from_array(val, i)?); + self.ordering_values.push(get_row_at_idx(ord, i)?) + } + } } Review Comment: Sure, we could do that. I'm not sure what is better - keep the tight loop separate or rely on branch prediction to get it right when there are no nulls. -- 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