punya opened a new issue, #27699: URL: https://github.com/apache/datafusion/issues/27699
### Describe the bug A window function in `|> WHERE` fails. BigQuery's [pipe syntax](https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax) uses this in place of `QUALIFY`: "use window functions inside a WHERE clause instead." ### To Reproduce ```sql SELECT * FROM (VALUES (1, 10), (1, 20), (2, 30)) AS t(k, v) |> WHERE row_number() OVER (PARTITION BY k ORDER BY v DESC) = 1; ``` ``` Error during planning: Window function calls are not allowed in WHERE: 'row_number() PARTITION BY [t.k] ORDER BY [t.v DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW' ``` Computing the window first works: ```sql SELECT * FROM (VALUES (1, 10), (1, 20), (2, 30)) AS t(k, v) |> EXTEND row_number() OVER (PARTITION BY k ORDER BY v DESC) AS rn |> WHERE rn = 1; ``` ### Expected behavior ``` k,v 1,20 2,30 ``` with the output columns unchanged, as for `SELECT * FROM t QUALIFY row_number() OVER (PARTITION BY k ORDER BY v DESC) = 1`. ### Additional context Part of #14660. -- 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]
