Skip to content

Commit

Permalink
feat(impala): implement ops.Radians, ops.Degress
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 016a082 commit a794ace
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
5 changes: 3 additions & 2 deletions ibis/backends/base/sql/registry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ def count_star(translator, op):
ops.Sin: unary("sin"),
ops.Tan: unary("tan"),
ops.Pi: fixed_arity("pi", 0),
ops.E: fixed_arity("exp(1)", 0),
ops.E: fixed_arity("e", 0),
ops.Degrees: lambda t, op: f"(180 * {t.translate(op.arg)} / {t.translate(ops.Pi())})",
ops.Radians: lambda t, op: f"({t.translate(ops.Pi())} * {t.translate(op.arg)} / 180)",
# Unary aggregates
ops.ApproxMedian: aggregate.reduction('appx_median'),
ops.ApproxCountDistinct: aggregate.reduction('ndv'),
Expand Down Expand Up @@ -354,7 +356,6 @@ def count_star(translator, op):
ops.DateTruncate: timestamp.truncate,
ops.IntervalFromInteger: timestamp.interval_from_integer,
# Other operations
ops.E: lambda *args: 'e()',
ops.Literal: literal,
ops.NullLiteral: null_literal,
ops.Cast: cast,
Expand Down
2 changes: 0 additions & 2 deletions ibis/backends/bigquery/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ def _interval_multiply(t, op):
ops.Floor: compiles_floor,
ops.Modulus: fixed_arity("MOD", 2),
ops.Sign: unary("SIGN"),
ops.Degrees: lambda t, op: f"(180 * {t.translate(op.arg)} / ACOS(-1))",
ops.Radians: lambda t, op: f"(ACOS(-1) * {t.translate(op.arg)} / 180)",
ops.BitwiseNot: lambda t, op: f"~ {t.translate(op.arg)}",
ops.BitwiseXor: lambda t, op: f"{t.translate(op.left)} ^ {t.translate(op.right)}",
ops.BitwiseOr: lambda t, op: f"{t.translate(op.left)} | {t.translate(op.right)}",
Expand Down
2 changes: 0 additions & 2 deletions ibis/backends/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,11 @@ def test_isnan_isinf(
L(5.556).radians(),
math.radians(5.556),
id='radians',
marks=pytest.mark.notimpl(["impala"], raises=com.OperationNotDefinedError),
),
param(
L(5.556).degrees(),
math.degrees(5.556),
id='degrees',
marks=pytest.mark.notimpl(["impala"], raises=com.OperationNotDefinedError),
),
param(L(11) % 3, 11 % 3, id='mod'),
],
Expand Down

0 comments on commit a794ace

Please sign in to comment.