Skip to content

Commit

Permalink
feat(pyspark): implement Where
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed May 30, 2022
1 parent ddbfc31 commit 32b9abb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,3 +2022,13 @@ def compile_radians(t, expr, scope, timecontext, **kwargs):
def compile_zero_if_null(t, expr, scope, timecontext, **kwargs):
col = t.translate(expr.op().arg, scope, timecontext, **kwargs)
return F.when(col.isNull() | F.isnan(col), F.lit(0)).otherwise(col)


@compiles(ops.Where)
def compile_where(t, expr, scope, timecontext, **kwargs):
op = expr.op()

return F.when(
t.translate(op.bool_expr, scope, timecontext, **kwargs),
t.translate(op.true_expr, scope, timecontext, **kwargs),
).otherwise(t.translate(op.false_null_expr, scope, timecontext, **kwargs))

0 comments on commit 32b9abb

Please sign in to comment.