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

   ## Summary
   
   - Adds a new `DecomposeAggregate` optimizer rule that rewrites `AVG(x)` into 
`CAST(SUM(x) AS Float64) / CAST(COUNT(*) AS Float64)`
   - Reduces accumulator overhead: AVG stores sum + count per group internally; 
splitting into separate SUM and COUNT accumulators is more efficient
   - Uses `COUNT(*)` for non-nullable args (enables sharing with existing 
`COUNT(*)` via CSE), falls back to `COUNT(x)` for nullable args
   - Only applies to AVG with Float64 return type; skips DISTINCT, filtered, 
ordered, and decimal/duration AVGs
   
   ## Test plan
   
   - [x] Unit tests for the optimizer rule (7 tests covering: no AVG, simple 
AVG, AVG with other aggregates, DISTINCT AVG skip, filtered AVG skip, multiple 
AVGs, no group-by)
   - [x] All sqllogic tests pass (aggregate, clickbench, tpch, explain, etc.)
   - [x] `cargo fmt` and `cargo clippy` clean
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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