Skip to content

Commit

Permalink
fix root names in pyspark reduction with nw.all()
Browse files Browse the repository at this point in the history
  • Loading branch information
camriddell committed Jan 10, 2025
1 parent 58dd1d2 commit fd24a5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion narwhals/_spark_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def func(df: SparkLikeLazyFrame) -> list[Column]:
for _input in inputs:
input_col_name = get_column_name(df, _input)
column_result = call(_input, **_kwargs)
if not returns_scalar:
if not returns_scalar or (
(self._depth == 0) and (self._function_name == "all")
):
column_result = column_result.alias(input_col_name)
results.append(column_result)
return results
Expand Down
2 changes: 1 addition & 1 deletion tests/expr_and_series/n_unique_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def test_n_unique(constructor: Constructor) -> None:
df = nw.from_native(constructor(data))
result = df.select(nw.col("a", "b").n_unique())
result = df.select(nw.all().n_unique())
expected = {"a": [3], "b": [4]}
assert_equal_data(result, expected)

Expand Down

0 comments on commit fd24a5e

Please sign in to comment.