jackylee-ch opened a new pull request, #24989:
URL: https://github.com/apache/datafusion/pull/24989

   ## Which issue does this PR close?
   
   - N/A
   
   ## Rationale for this change
   
   `bit_xor(DISTINCT c)` with `GROUP BY` fails with `Invalid argument error: 
column types must match schema types, expected List(Int16) but found Int16`. 
`groups_accumulator_supported` ignored `is_distinct`, so the plan got the 
non-distinct `PrimitiveGroupsAccumulator` while `state_fields` declared the 
distinct `List` state. XOR is also not idempotent, so duplicates change the 
result: `5 ^ 5 ^ 9 = 9` but `5 ^ 9 = 12`.
   
   ## What changes are included in this PR?
   
   `groups_accumulator_supported` now returns `!args.is_distinct`, matching 
`sum`, `avg` and `count`.
   
   ## What is the testing strategy for this PR?
   
   Two `aggregate.slt` queries covering the two shapes 
`SingleDistinctToGroupBy` does not rewrite (a non-distinct aggregate alongside, 
and a `FILTER`). Both fail on `main` with the error above and pass with this 
change.
   
   ## Are there any user-facing changes?
   
   `bit_and`/`bit_or`/`bit_xor` with `DISTINCT` and `GROUP BY` now return 
correct results. No API change.
   


-- 
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]

Reply via email to