Skip to content

Apache DataFusion SQL Query Engine

Minor: Add comments about initial value for `BitAnd` accumulator (#6964)

Andrew Lamb06c33cf0ef3e
diff --git a/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs b/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
index 6a2d509389..4c7733520e 100644
--- a/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
+++ b/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
@@ -278,6 +278,9 @@ impl AggregateExpr for BitAnd {
fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>> {
use std::ops::BitAndAssign;
+ // Note the default value for BitAnd should be all set
+ // (e.g. `0b11...111`) use MAX / -1 here to get appropriate
+ // bit pattern for each type
match self.data_type {
DataType::Int8 => {
instantiate_accumulator!(self, -1, Int8Type, |x, y| x.bitand_assign(y))