pub fn check_no_window_functions(expr: &Expr, clause: &str) -> Result<()>Expand description
Returns an error if expr contains a window function call.
clause names where expr came from and completes the message
Window function calls are not allowed in {clause}, for example WHERE or
HAVING. Filters are evaluated before window functions are computed, so a
window call in a filter predicate has no physical equivalent and is not
valid SQL either (PostgreSQL: window functions are not allowed in HAVING).
Rejecting it while the logical plan is built gives an error that names the
offending call instead of a late physical planning failure.
Filter::try_new calls this for every predicate, so the SQL planner and
the DataFrame/LogicalPlanBuilder paths are covered without callers
invoking it directly. Window calls inside subqueries of expr are not
visited and are legal.
The error is built by window_function_not_allowed_err with the best
effort span of the call (see Expr::spans) and a generic help message. A
caller that knows where the call is in the original query, such as the SQL
planner, can build a more precise error with that function directly.