Github user hvanhovell commented on the pull request:
https://github.com/apache/spark/pull/6104#issuecomment-101519756
Hi,
In the JIRA the following examples is given:
```
df.select(
df.store,
df.date,
df.sales,
avg(df.sales).over.partitionBy(df.store)
.orderBy(df.store)
.rowsFollowing(0) // this means from unbounded
preceding to current row
)
```
Is there a reason for why the aggregation operation has moved from the
beginning (the style in the JIRA), to the end (style above)? Are both still
possible? I'd prefer the former, since it seems a bit shorter, and more
recognizable comming from SQL.
On a related note. Is it also an idea to be able to create a seperate
window (groupBy/orderBy) definition and use this definition in one or more
windowed aggregates. For example:
```
val window = partitionBy($"store").orderBy($"date)
df.select (
$"store"
,$"date"
,sum($"sales").over(window).rowsFollowing(0).as("TotalSales")
,sum($"sales").over(window).rowsFollowing(0).rowsPreceding(2).as("SalesLast3M")
)
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]