Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions python/pyspark/sql/connect/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,11 @@ def _convert_measure(
) -> proto.Aggregate.AggregateFunction:
exp, fun = m
measure = proto.Aggregate.AggregateFunction()
measure.function.name = fun # type: ignore[attr-defined]
measure.function.name = fun
if type(exp) is str:
measure.function.arguments.append( # type: ignore[attr-defined]
self.unresolved_attr(exp)
)
measure.function.arguments.append(self.unresolved_attr(exp))
else:
measure.function.arguments.append( # type: ignore[attr-defined]
cast(Expression, exp).to_plan(session)
)
measure.function.arguments.append(cast(Expression, exp).to_plan(session))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is formatted by the python formatter.

return measure

def plan(self, session: Optional["RemoteSparkSession"]) -> proto.Relation:
Expand All @@ -339,13 +335,13 @@ def plan(self, session: Optional["RemoteSparkSession"]) -> proto.Relation:

agg = proto.Relation()
agg.aggregate.input.CopyFrom(self._child.plan(session))
agg.aggregate.measures.extend( # type: ignore[attr-defined]
agg.aggregate.measures.extend(
list(map(lambda x: self._convert_measure(x, session), self.measures))
)

gs = proto.Aggregate.GroupingSet() # type: ignore[attr-defined]
gs = proto.Aggregate.GroupingSet()
gs.aggregate_expressions.extend(groupings)
agg.aggregate.grouping_sets.append(gs) # type: ignore[attr-defined]
agg.aggregate.grouping_sets.append(gs)
return agg

def print(self, indent: int = 0) -> str:
Expand Down