akshat-lakhera opened a new pull request, #27874:
URL: https://github.com/apache/datafusion/pull/27874

   ## Which issue does this PR close?
   
   - Closes #27699 (Window functions fail in |> WHERE).
   
   ## Rationale for this change
   
   Pipe WHERE (|> WHERE) acts as the pipe syntax equivalent of QUALIFY when 
filtering over window function expressions, but it previously delegated 
directly to plan_selection, which rejected all window functions with "Window 
function calls are not allowed in WHERE".
   
   ## What changes are included in this PR?
   
   - In datafusion/sql/src/select.rs, factored plan_selection into 
plan_selection_internal(..., allow_window_functions: bool) and added 
plan_pipe_selection. Standard SQL WHERE keeps allow_window_functions = false 
with the existing error message and span diagnostics, while pipe WHERE allows 
window expressions (still rejecting direct aggregate calls), computes them with 
LogicalPlanBuilder::window_plan, rebases the filter predicate with rebase_expr, 
filters, and projects back to the original input schema columns.
   - In datafusion/sql/src/query.rs, updated PipeOperator::Where handling to 
call plan_pipe_selection.
   - Added SQL planner snapshot tests in 
datafusion/sql/tests/sql_integration.rs and end-to-end execution coverage in 
datafusion/sqllogictest/test_files/pipe_operator.slt (covering single/multiple 
window predicates, chained pipe stages, and aggregate function rejection).
   
   ## What is the testing strategy for this PR?
   
   - Ran cargo fmt -p datafusion-sql -- --check (passed).
   - Ran cargo clippy -p datafusion-sql --all-targets -- -D warnings (passed 
with zero warnings).
   - Ran cargo test -p datafusion-sql (105 unit tests passed, 618 
sql_integration tests passed, 12 doc-tests passed and 1 ignored).
   - Ran cargo test -p datafusion-sqllogictest -- pipe_operator 
(pipe_operator.slt passed).
   
   ## Are there any user-facing changes?
   
   Users can now use window functions directly inside pipe |> WHERE filters 
without triggering a WHERE window function planning error. Standard SQL WHERE 
behavior is unchanged.
   


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