zhengruifeng commented on code in PR #39925:
URL: https://github.com/apache/spark/pull/39925#discussion_r1100881055
##########
python/pyspark/sql/connect/plan.py:
##########
@@ -673,32 +716,34 @@ def plan(self, session: "SparkConnectClient") ->
proto.Relation:
from pyspark.sql.connect.functions import lit
assert self._child is not None
+ plan = proto.Relation()
+ plan.common.plan_id = self._plan_id
- agg = proto.Relation()
-
- agg.aggregate.input.CopyFrom(self._child.plan(session))
+ plan.aggregate.input.CopyFrom(self._child.plan(session))
- agg.aggregate.grouping_expressions.extend([c.to_plan(session) for c in
self._grouping_cols])
- agg.aggregate.aggregate_expressions.extend(
+ plan.aggregate.grouping_expressions.extend(
+ [c.to_plan(session) for c in self._grouping_cols]
+ )
+ plan.aggregate.aggregate_expressions.extend(
[c.to_plan(session) for c in self._aggregate_cols]
)
if self._group_type == "groupby":
- agg.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_GROUPBY
+ plan.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_GROUPBY
elif self._group_type == "rollup":
- agg.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_ROLLUP
+ plan.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_ROLLUP
elif self._group_type == "cube":
- agg.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_CUBE
+ plan.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_CUBE
elif self._group_type == "pivot":
- agg.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_PIVOT
+ plan.aggregate.group_type =
proto.Aggregate.GroupType.GROUP_TYPE_PIVOT
assert self._pivot_col is not None
- agg.aggregate.pivot.col.CopyFrom(self._pivot_col.to_plan(session))
+ plan.aggregate.pivot.col.CopyFrom(self._pivot_col.to_plan(session))
if self._pivot_values is not None and len(self._pivot_values) > 0:
- agg.aggregate.pivot.values.extend(
+ plan.aggregate.pivot.values.extend(
[lit(v).to_plan(session).literal for v in
self._pivot_values]
)
- return agg
+ return plan
Review Comment:
both `plan` and `rel` are fine to me, I just want to make the naming
consistent.
--
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]