Skip to content

Commit db13241

Browse files
cpcloudkszucs
authored andcommitted
feat(pyspark): implement zeroifnull
1 parent 4735e9a commit db13241

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ibis/backends/pyspark/compiler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,3 +2012,9 @@ def compile_degrees(t, expr, scope, timecontext, **kwargs):
20122012
@compiles(ops.Radians)
20132013
def compile_radians(t, expr, scope, timecontext, **kwargs):
20142014
return F.radians(t.translate(expr.op().arg, scope, timecontext, **kwargs))
2015+
2016+
2017+
@compiles(ops.ZeroIfNull)
2018+
def compile_zero_if_null(t, expr, scope, timecontext, **kwargs):
2019+
col = t.translate(expr.op().arg, scope, timecontext, **kwargs)
2020+
return F.when(col.isNull() | F.isnan(col), F.lit(0)).otherwise(col)

ibis/backends/tests/test_generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def test_logical_negation_column(backend, alltypes, df, op):
546546
backend.assert_series_equal(result, expected, check_names=False)
547547

548548

549-
@pytest.mark.notimpl(["dask", "datafusion", "pandas", "pyspark"])
549+
@pytest.mark.notimpl(["dask", "datafusion", "pandas"])
550550
@pytest.mark.parametrize(
551551
("dtype", "zero", "expected"),
552552
[("int64", 0, 1), ("float64", 0.0, 1.0)],
@@ -559,7 +559,7 @@ def test_zeroifnull_literals(con, dtype, zero, expected):
559559
)
560560

561561

562-
@pytest.mark.notimpl(["dask", "datafusion", "pandas", "pyspark"])
562+
@pytest.mark.notimpl(["dask", "datafusion", "pandas"])
563563
def test_zeroifnull_column(backend, alltypes, df):
564564
expr = alltypes.int_col.nullif(1).zeroifnull()
565565
result = expr.execute()

0 commit comments

Comments
 (0)