You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
first_value doesn't work when applied to window function output #1300
Describe the bug
A clear and concise description of what the bug is.
If I generate a column based on a window function then try to filter and select the first value it barfs
Hi, I would like to work on this issue. I have successfully reproduced the crash on the latest main branch using the script provided. Could you please assign it to me?
I have investigated this issue. The crash happens because first_value (an aggregate function) is being called inside .select(), which is not supported by the physical planner.
I confirmed that using .aggregate([], [F.first_value(...)]) works correctly.
I would like to contribute a documentation fix to clarify that aggregate functions must be used within .aggregate() and not .select(). Can I be assigned?
Activity
timsaucer commentedon Nov 5, 2025
You can work around this by setting the window on the function (using
.over()), but yes this is clearly a bug.ntjohnson1 commentedon Nov 7, 2025
Confirmed the work around
ntjohnson1 commentedon Nov 12, 2025
Hmm on 50.1 this seems just generally broken or the example in the docs is wrong
Exception: DataFusion error: NotImplemented("Physical plan does not support logical expression AggregateFunction(AggregateFunction { func: AggregateUDF { inner: LastValue { name: \"last_value\", signature: Signature { type_signature: Any(1), volatility: Immutable }, accumulator: \"<FUNC>\" } }, params: AggregateFunctionParams { args: [Column(Column { relation: Some(Bare { table: \"cfca6f9a4517040a69c659bb43f2a9617\" }), name: \"a\" })], distinct: false, filter: None, order_by: [Sort { expr: Column(Column { relation: Some(Bare { table: \"cfca6f9a4517040a69c659bb43f2a9617\" }), name: \"b\" }), asc: true, nulls_first: true }], null_treatment: Some(RespectNulls) } })")AdMub commentedon Jan 22, 2026
Hi, I would like to work on this issue. I have successfully reproduced the crash on the latest main branch using the script provided. Could you please assign it to me?
AdMub commentedon Jan 22, 2026
I have investigated this issue. The crash happens because first_value (an aggregate function) is being called inside .select(), which is not supported by the physical planner.
I confirmed that using .aggregate([], [F.first_value(...)]) works correctly.
I would like to contribute a documentation fix to clarify that aggregate functions must be used within .aggregate() and not .select(). Can I be assigned?
docs: Add warning to first_value about usage in select vs aggregate
docs: Clarify first_value usage in select vs aggregate (apache#1348)