Skip to content

Commit

Permalink
feat(flink): implement translation of NULLIFZERO
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and jcrist committed Sep 8, 2023
1 parent 28f45d0 commit 6ad1e96
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ibis/backends/flink/registry.py
Expand Up @@ -70,6 +70,11 @@ def _literal(translator: ExprTranslator, op: ops.Literal) -> str:
return translate_literal(op)


def _nullifzero(translator: ExprTranslator, op: ops.Literal) -> str:
casted = translate_literal(ops.Literal("0", dtype=op.dtype))
return f"NULLIF({translator.translate(op.arg)}, {casted})"


def _format_window_start(translator: ExprTranslator, boundary):
if boundary is None:
return "UNBOUNDED PRECEDING"
Expand Down Expand Up @@ -193,6 +198,7 @@ def _window(translator: ExprTranslator, op: ops.Node) -> str:
ops.ExtractMinute: _extract_field("minute"), # equivalent to MINUTE(timestamp)
ops.ExtractSecond: _extract_field("second"), # equivalent to SECOND(timestamp)
ops.Literal: _literal,
ops.NullIfZero: _nullifzero,
ops.Degrees: unary("degrees"),
ops.Radians: unary("radians"),
ops.RegexSearch: fixed_arity("regexp", 2),
Expand Down

0 comments on commit 6ad1e96

Please sign in to comment.