Skip to content

Commit

Permalink
feat(pyspark): implement nullifzero
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed May 19, 2022
1 parent addb2c1 commit 640234b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1923,3 +1923,10 @@ def compile_unnest(t, expr, scope, timecontext, **kwargs):
op = expr.op()
column = t.translate(op.arg, scope, timecontext, **kwargs)
return F.explode(column)


@compiles(ops.NullIfZero)
def compile_null_if_zero(t, expr, scope, timecontext, **kwargs):
op = expr.op()
arg = t.translate(op.arg, scope, timecontext, **kwargs)
return F.when(arg == 0, F.lit(None)).otherwise(arg)

0 comments on commit 640234b

Please sign in to comment.