alamb commented on code in PR #14360:
URL: https://github.com/apache/datafusion/pull/14360#discussion_r1934250018
##########
datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive.rs:
##########
@@ -166,10 +165,12 @@ where
null_idx: Option<usize>,
) -> PrimitiveArray<T> {
let nulls = null_idx.map(|null_idx| {
- let mut buffer = BooleanBufferBuilder::new(values.len());
- buffer.append_n(values.len(), true);
- buffer.set_bit(null_idx, false);
- unsafe { NullBuffer::new_unchecked(buffer.finish(), 1) }
+ let mut buffer = NullBufferBuilder::new(values.len());
+ buffer.append_n_non_nulls(null_idx);
+ buffer.append_null();
+ buffer.append_n_non_nulls(values.len() - null_idx - 1);
+ // SAFETY: The inner builder must be constructed
Review Comment:
"SAFETY" is typically used to justify the use of `unsafe`
Since this is not `unsafe` (`unwrap()` will panic not lead to undefined
behavior) I think we should use a different tag here
```suggestion
// NOTE: The inner builder must be constructed as there is
at least one null
```
--
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]