From 7e61391819f17ce87f1f63123fd8862a18eb3098 Mon Sep 17 00:00:00 2001 From: Krzysztof Date: Thu, 16 Feb 2023 02:52:56 +0100 Subject: [PATCH] feat(datafusion): implement ops.Degress, ops.Radians --- ibis/backends/datafusion/compiler.py | 10 ++++++++++ ibis/backends/tests/test_numeric.py | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ibis/backends/datafusion/compiler.py b/ibis/backends/datafusion/compiler.py index aecd2ec9a1c7..2227d20addfb 100644 --- a/ibis/backends/datafusion/compiler.py +++ b/ibis/backends/datafusion/compiler.py @@ -428,6 +428,16 @@ def cot(op): return df.lit(1.0) / df.functions.tan(x) +@translate.register(ops.Radians) +def radians(op): + return translate(op.arg) * df.lit(math.pi) / df.lit(180) + + +@translate.register(ops.Degrees) +def degrees(op): + return translate(op.arg) * df.lit(180) / df.lit(math.pi) + + @translate.register(ops.RandomScalar) def random_scalar(_): return df.functions.random() diff --git a/ibis/backends/tests/test_numeric.py b/ibis/backends/tests/test_numeric.py index 8c5d17af361f..43480a0ccfc1 100644 --- a/ibis/backends/tests/test_numeric.py +++ b/ibis/backends/tests/test_numeric.py @@ -733,17 +733,13 @@ def test_isnan_isinf( L(5.556).radians(), math.radians(5.556), id='radians', - marks=pytest.mark.notimpl( - ["datafusion", "impala"], raises=com.OperationNotDefinedError - ), + marks=pytest.mark.notimpl(["impala"], raises=com.OperationNotDefinedError), ), param( L(5.556).degrees(), math.degrees(5.556), id='degrees', - marks=pytest.mark.notimpl( - ["datafusion", "impala"], raises=com.OperationNotDefinedError - ), + marks=pytest.mark.notimpl(["impala"], raises=com.OperationNotDefinedError), ), param(L(11) % 3, 11 % 3, id='mod'), ],