Skip to content

Commit

Permalink
feat(datafusion): implement ops.Degress, ops.Radians
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Feb 16, 2023
1 parent 5d1cd0f commit 7e61391
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 10 additions & 0 deletions ibis/backends/datafusion/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 2 additions & 6 deletions ibis/backends/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
Expand Down

0 comments on commit 7e61391

Please sign in to comment.