Skip to content

Commit 4efb2b4

Browse files
committed
chore: Use an enum to express the different kinds of nullability in an array
Follow-up of apache#17726 (review)
1 parent c2921e0 commit 4efb2b4

File tree

1 file changed

+12
-6
lines changed
  • datafusion/physical-plan/src/aggregates/group_values/multi_group_by

1 file changed

+12
-6
lines changed

datafusion/physical-plan/src/aggregates/group_values/multi_group_by/boolean.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,26 @@ impl<const NULLABLE: bool> GroupColumn for BooleanGroupValueBuilder<NULLABLE> {
110110
}
111111

112112
fn vectorized_append(&mut self, array: &ArrayRef, rows: &[usize]) -> Result<()> {
113+
enum Nulls {
114+
All,
115+
Some,
116+
None,
117+
}
118+
113119
let arr = array.as_boolean();
114120

115121
let null_count = array.null_count();
116122
let num_rows = array.len();
117123
let all_null_or_non_null = if null_count == 0 {
118-
Some(true)
124+
Nulls::None
119125
} else if null_count == num_rows {
120-
Some(false)
126+
Nulls::All
121127
} else {
122-
None
128+
Nulls::Some
123129
};
124130

125131
match (NULLABLE, all_null_or_non_null) {
126-
(true, None) => {
132+
(true, Nulls::Some) => {
127133
for &row in rows {
128134
if array.is_null(row) {
129135
self.nulls.append(true);
@@ -135,14 +141,14 @@ impl<const NULLABLE: bool> GroupColumn for BooleanGroupValueBuilder<NULLABLE> {
135141
}
136142
}
137143

138-
(true, Some(true)) => {
144+
(true, Nulls::None) => {
139145
self.nulls.append_n(rows.len(), false);
140146
for &row in rows {
141147
self.buffer.append(arr.value(row));
142148
}
143149
}
144150

145-
(true, Some(false)) => {
151+
(true, Nulls::All) => {
146152
self.nulls.append_n(rows.len(), true);
147153
self.buffer.append_n(rows.len(), bool::default());
148154
}

0 commit comments

Comments
 (0)