Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix root names in pyspark reduction with nw.all() #1787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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")
Copy link
Member

Choose a reason for hiding this comment

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

thanks for looking into this!

I think this might be too specific and that we'll need a more generic solution - will look into it and let you know

):
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
Loading