-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22239][SQL][Python] Enable grouped aggregate pandas UDFs as window functions with unbounded window frames #21082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
659e1df
8e00adb
a9b30df
04ae99f
5cb5c91
abdfd9e
4cfd5c4
27b6449
6864148
5140e2c
e54ea6b
019096b
136d83d
17e6578
328b2c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,10 +133,8 @@ def wrap_window_agg_pandas_udf(f, return_type): | |
|
|
||
| def wrapped(*series): | ||
| import pandas as pd | ||
| import numpy as np | ||
| result = f(*series) | ||
| # This doesn't work with non primitive types | ||
| return pd.Series(np.repeat(result, len(series[0]))) | ||
| return pd.Series([result]).repeat(len(series[0])) | ||
|
||
|
|
||
| return lambda *a: (wrapped(*a), arrow_return_type) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,9 +113,14 @@ trait CheckAnalysis extends PredicateHelper { | |
| failAnalysis("An offset window function can only be evaluated in an ordered " + | ||
| s"row-based window frame with a single offset: $w") | ||
|
|
||
| case w @ WindowExpression(_: PythonUDF, | ||
| WindowSpecDefinition(_, _, frame: SpecifiedWindowFrame)) | ||
|
||
| if !frame.isUnbounded => | ||
| failAnalysis(s"Only unbounded window frame is supported with Python UDFs.") | ||
|
|
||
| case w @ WindowExpression(e, s) => | ||
| // Only allow window functions with an aggregate expression or an offset window | ||
| // function. | ||
| // function or a Pandas window UDF. | ||
| e match { | ||
| case _: AggregateExpression | _: OffsetWindowFunction | _: AggregateWindowFunction => | ||
| w | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated, but I figured its shouldn't hurt to add an array test in GroupedAggPandasUDFTests..