punya opened a new issue, #27680:
URL: https://github.com/apache/datafusion/issues/27680
### Describe the bug
A window function in a piped `EXTEND` or `SELECT` plans but fails when the
physical plan is built. The same expression works in a normal `SELECT`.
### To Reproduce
```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
```
```
This feature is not implemented: Physical plan does not support logical
expression WindowFunction(WindowFunction { fun: WindowUDF(WindowUDF { inner:
RowNumber { ... } }), ... })
```
`|> SELECT k, v, ROW_NUMBER() OVER (PARTITION BY k ORDER BY v DESC) AS rn`
fails the same way. Without pipes, this works:
```sql
SELECT k, v, ROW_NUMBER() OVER (PARTITION BY k ORDER BY v DESC) AS rn
FROM (VALUES (1, 10), (1, 20), (2, 30)) AS t(k, v)
```
Seen on DataFusion 55.3.0 and in the 55.0.0 Python bindings.
### Expected behavior
```
+---+----+----+
| k | v | rn |
+---+----+----+
| 1 | 20 | 1 |
| 2 | 30 | 1 |
+---+----+----+
```
### Additional context
The pipe operators seem to build a plain projection, without the window
planning a normal `SELECT` gets. `EXTEND ... OVER (...) |> WHERE` is how pipe
syntax keeps the latest row per key, and `LAG` and `LEAD` need the same
planning. 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]