Skip to content

Commit

Permalink
Rework logic a little to avoid nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Aug 30, 2024
1 parent b5de1eb commit 1634cb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/cudf_polars/cudf_polars/dsl/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,10 @@ def collect_agg(self, *, depth: int) -> AggInfo:
raise NotImplementedError("Nan propagation in groupby for min/max")
(child,) = self.children
((expr, _, _),) = child.collect_agg(depth=depth + 1).requests
request = self.request
# These are handled specially here because we don't set up the
# request for the whole-frame agg because we can avoid a
# reduce for these.
if self.name == "first":
request = plc.aggregation.nth_element(
0, null_handling=plc.types.NullPolicy.INCLUDE
Expand All @@ -1548,8 +1552,6 @@ def collect_agg(self, *, depth: int) -> AggInfo:
request = plc.aggregation.nth_element(
-1, null_handling=plc.types.NullPolicy.INCLUDE
)
else:
request = self.request
if request is None:
raise NotImplementedError(
f"Aggregation {self.name} in groupby"
Expand Down

0 comments on commit 1634cb6

Please sign in to comment.