Dodothereal opened a new pull request, #26753:
URL: https://github.com/apache/datafusion/pull/26753

   Closes #25375.
   
   The Spark aggregates all reported the default `Sensitive` handling for 
`DISTINCT`, even though their accumulators behave differently. `collect_set` 
always deduplicates, while `collect_list`, `try_sum`, and `avg` do not read the 
`DISTINCT` flag.
   
   This declares `collect_set` as `Insensitive` and the other three as 
`Unsupported`. The optimizer can now remove a redundant `DISTINCT` from 
`collect_set`. For the other functions, this records the current gap; it does 
not make their accumulators support `DISTINCT`.
   
   Making `Unsupported` explicit is conservative for join elimination: an 
aggregate with a filter no longer counts as duplicate-insensitive and therefore 
keeps an inner join instead of being eliminated as a semijoin. 
`SingleDistinctToGroupBy` still deduplicates single-argument forms, so their 
results stay the same.
   
   The tests cover the four declarations and check through `EXPLAIN` that 
`collect_set(DISTINCT a)` is planned as `collect_set(a)`. A result test with 
duplicates covers the same path.
   
   Tests run:
   
   - `cargo test -p datafusion-spark --lib aggregate`
   - `cargo test -p datafusion-sqllogictest --test sqllogictests -- 
spark/aggregate/collect --test-threads 1`
   - `cargo test -p datafusion-optimizer --lib`
   - `cargo clippy -p datafusion-spark --lib -- -D warnings`
   - `cargo fmt --all -- --check`
   


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