|
9 | 9 | from narwhals._plan._dispatch import get_dispatch_name |
10 | 10 | from narwhals._plan._guards import is_agg_expr, is_function_expr |
11 | 11 | from narwhals._plan.arrow import acero, functions as fn, options |
12 | | -from narwhals._plan.common import temp |
13 | 12 | from narwhals._plan.compliant.group_by import EagerDataFrameGroupBy |
14 | 13 | from narwhals._plan.expressions import aggregation as agg |
15 | 14 | from narwhals._utils import Implementation |
@@ -157,15 +156,14 @@ def compliant(self) -> Frame: |
157 | 156 | return self._df |
158 | 157 |
|
159 | 158 | def __iter__(self) -> Iterator[tuple[Any, Frame]]: |
160 | | - temp_name = temp.column_name(self.compliant) |
161 | | - native = self.compliant.native |
162 | | - composite_values = concat_str(acero.select_names_table(native, self.key_names)) |
163 | | - re_keyed = native.add_column(0, temp_name, composite_values) |
| 159 | + from narwhals._plan.arrow.dataframe import partition_by |
| 160 | + |
| 161 | + by = self.key_names |
164 | 162 | from_native = self.compliant._with_native |
165 | | - for v in composite_values.unique(): |
166 | | - t = from_native(acero.filter_table(re_keyed, pc.field(temp_name) == v)) |
| 163 | + for partition in partition_by(self.compliant.native, by): |
| 164 | + t = from_native(partition) |
167 | 165 | yield ( |
168 | | - t.select_names(*self.key_names).row(0), |
| 166 | + t.select_names(*by).row(0), |
169 | 167 | t.select_names(*self._column_names_original), |
170 | 168 | ) |
171 | 169 |
|
|
0 commit comments