From 640234b95d0cd43d69508f2c968253474f00f118 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 16 May 2022 09:26:41 -0400 Subject: [PATCH] feat(pyspark): implement nullifzero --- ibis/backends/pyspark/compiler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ibis/backends/pyspark/compiler.py b/ibis/backends/pyspark/compiler.py index b4ecd701d9cf..7a4688a2b1d6 100644 --- a/ibis/backends/pyspark/compiler.py +++ b/ibis/backends/pyspark/compiler.py @@ -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)