You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/09/30 13:15:52 UTC

(datafusion) branch gh-readonly-queue/main/pr-25687-dd1d709929c349fc1dfd47dc1069a8d7a5e6f0ea created (now 884465c201)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-25687-dd1d709929c349fc1dfd47dc1069a8d7a5e6f0ea
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at 884465c201 fix: reject groups accumulator for NULL-typed bitwise aggregates (#25687)

This branch includes the following new commits:

     new 884465c201 fix: reject groups accumulator for NULL-typed bitwise aggregates (#25687)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: fix: reject groups accumulator for NULL-typed bitwise aggregates (#25687)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-25687-dd1d709929c349fc1dfd47dc1069a8d7a5e6f0ea
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 884465c2014718cdcacaa908bec125fa68579413
Author: jackylee <qc...@gmail.com>
AuthorDate: Wed Sep 30 13:15:27 2026 +0000

    fix: reject groups accumulator for NULL-typed bitwise aggregates (#25687)
    
    ## Which issue does this PR close?
    
    - N/A
    
    ## Rationale for this change
    
    `bit_and(NULL)` with `GROUP BY` fails with `GroupsAccumulator not
    supported for bit_and with Null`: `groups_accumulator_supported`
    returned true for a Null return type, but `create_groups_accumulator`'s
    `downcast_integer!` has no Null arm, so the grouped path hits
    `not_impl_err`.
    
    ## What changes are included in this PR?
    
    `groups_accumulator_supported` now returns false for a Null return type,
    so the plan falls back to the scalar accumulator (which handles Null via
    `NoopAccumulator`). Same shape as the existing `bit_xor(DISTINCT)`
    guard.
    
    ## What is the testing strategy for this PR?
    
    An `aggregate.slt` case: `bit_and`/`bit_or`/`bit_xor(NULL)` with `GROUP
    BY`, which fails on `main` and returns NULL per group with this change.
    
    ## Are there any user-facing changes?
    
    `bit_and`/`bit_or`/`bit_xor` over NULL with `GROUP BY` now returns NULL
    instead of erroring. No API change.
---
 datafusion/functions-aggregate/src/bit_and_or_xor.rs |  5 +++++
 datafusion/sqllogictest/test_files/aggregate.slt     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/datafusion/functions-aggregate/src/bit_and_or_xor.rs b/datafusion/functions-aggregate/src/bit_and_or_xor.rs
index 477ad6f1ef..1928f5c51c 100644
--- a/datafusion/functions-aggregate/src/bit_and_or_xor.rs
+++ b/datafusion/functions-aggregate/src/bit_and_or_xor.rs
@@ -292,6 +292,11 @@ impl AggregateUDFImpl for BitwiseOperation {
     }
 
     fn groups_accumulator_supported(&self, args: AccumulatorArgs) -> bool {
+        if args.return_field.data_type().is_null() {
+            // A Null input has no integer groups accumulator (see
+            // create_groups_accumulator), so fall back to the scalar accumulator.
+            return false;
+        }
         // DISTINCT only changes the result of XOR; AND and OR are idempotent
         !(args.is_distinct && self.operation == BitwiseOperationType::Xor)
     }
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.slt
index b3f8a5515d..b9dacfa925 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -5161,6 +5161,25 @@ statement ok
 drop table bit_distinct;
 
 
+# bitwise aggregates over NULL inputs, with and without GROUP BY
+statement ok
+create table bit_null (tag varchar) as values ('A'), ('A'), ('B');
+
+query ???
+SELECT bit_and(NULL), bit_or(NULL), bit_xor(NULL) FROM bit_null;
+----
+NULL NULL NULL
+
+query ???T
+SELECT bit_and(NULL), bit_or(NULL), bit_xor(NULL), tag FROM bit_null GROUP BY tag ORDER BY tag;
+----
+NULL NULL NULL A
+NULL NULL NULL B
+
+statement ok
+drop table bit_null;
+
+
 # bit_and_i32
 statement ok
 create table t (c int) as values (4), (7), (15);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org