From 6ad1e969b40b09f0acb68cbd74c223c5ee36332b Mon Sep 17 00:00:00 2001 From: Deepyaman Datta Date: Fri, 8 Sep 2023 09:05:37 -0600 Subject: [PATCH] feat(flink): implement translation of `NULLIFZERO` --- ibis/backends/flink/registry.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ibis/backends/flink/registry.py b/ibis/backends/flink/registry.py index 2e0a8ebe397c..5981d937c77e 100644 --- a/ibis/backends/flink/registry.py +++ b/ibis/backends/flink/registry.py @@ -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" @@ -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),