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

feat: add drop_nulls, fill_null, and filter Spark Expressions #1802

Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
branch to handle if strategy is None
lucas-nelson-uiuc committed Jan 12, 2025
commit 8a5b3627173799bbb8ad01e60412f2ca3ba4f3a3
22 changes: 13 additions & 9 deletions narwhals/_spark_like/expr.py
Original file line number Diff line number Diff line change
@@ -314,15 +314,19 @@ def _fill_null(_input: Column) -> Column:
msg = "must specify either a fill `value` or `strategy`"
raise ValueError(msg)

fill_value = value
match strategy:
case "zero":
fill_value = F.lit(0)
case "one":
fill_value = F.lit(1)
case _:
msg = f"strategy not supported: {strategy}"
raise ValueError(msg)
# TODO(unauthored): can only specify `limit` when strategy is set to 'backward' or 'forward'

if strategy is not None:
match strategy:
case "zero":
fill_value = F.lit(0)
case "one":
fill_value = F.lit(1)
case _:
msg = f"strategy not supported: {strategy}"
raise ValueError(msg)
else:
fill_value = value

return F.ifnull(_input, fill_value)