Adam-Alani opened a new pull request, #24005:
URL: https://github.com/apache/datafusion/pull/24005

   ## Why
   
   Aggregate arguments that are constant can lose that property when a subquery 
or CTE projects them as columns. `approx_percentile_cont` then rejects a 
projected literal because its accumulator cannot evaluate the physical column 
without input, even though the defining expression is query-global and constant.
   
   ## What
   
   This preserves column-free, non-volatile aggregate arguments through 
projection and subquery-alias boundaries so normal expression simplification 
can evaluate them before physical planning. Row-varying columns remain 
unchanged and continue to be rejected by percentile validation.
   
   ## How
   
   The simplify-expressions rule collects safe constant definitions from 
projection chains, remaps them through subquery aliases, and substitutes only 
matching aggregate-expression columns while preserving output names. Scalar 
subqueries, volatile expressions, and expressions with column dependencies are 
excluded.
   
   Validated with:
   
   - `cargo test --test sqllogictests -p datafusion-sqllogictest -- 
aggregate.slt`
   - `cargo test -p datafusion-optimizer simplify_expressions::simplify_exprs`
   - `cargo clippy -p datafusion-optimizer --all-features -- -D warnings`
   - `cargo fmt --all -- --check`
   
   Companion to #23997; the PRs are independent and can merge in either order.


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