zhengruifeng commented on code in PR #38768:
URL: https://github.com/apache/spark/pull/38768#discussion_r1031102422
##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -51,24 +52,11 @@
class GroupingFrame(object):
Review Comment:
not related to this PR, but shall we rename it `GroupedData` to be the same
with pyspark?
##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -164,8 +156,20 @@ def selectExpr(self, *expr: Union[str, List[str]]) ->
"DataFrame":
return DataFrame.withPlan(plan.Project(self._plan, *sql_expr),
session=self._session)
- def agg(self, exprs: Optional[GroupingFrame.MeasuresType]) -> "DataFrame":
- return self.groupBy().agg(exprs)
+ def agg(self, *exprs: Union[Expression, Dict[str, str]]) -> "DataFrame":
+ if not exprs:
+ raise ValueError("Argument 'exprs' must not be empty")
+
+ if len(exprs) == 1 and isinstance(exprs[0], dict):
+ measures = []
+ for e, fun in exprs[0].items():
+ measures.append(ScalarFunctionExpression(fun, Column(e)))
Review Comment:
```suggestion
measures = [ScalarFunctionExpression(f, Column(e)) for e, f in
exprs[0].items()]
```
--
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]