Skip to content

Commit

Permalink
fix(mssql): fix round without argument
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Dec 27, 2022
1 parent 49321a6 commit 52a60ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ibis/backends/mssql/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ def translator(t, op):
return translator


def _round(t, op):
sa_arg = t.translate(op.arg)

if op.digits is not None:
return sa.func.round(sa_arg, t.translate(op.digits))
else:
return sa.func.round(sa_arg, 0)


operation_registry = sqlalchemy_operation_registry.copy()
operation_registry.update(sqlalchemy_window_functions_registry)

Expand Down Expand Up @@ -113,6 +122,7 @@ def translator(t, op):
ops.Sin: unary(sa.func.sin),
ops.Sqrt: unary(sa.func.sqrt),
ops.Tan: unary(sa.func.tan),
ops.Round: _round,
# timestamp methods
ops.TimestampNow: fixed_arity(sa.func.GETDATE, 0),
ops.ExtractYear: _extract('year'),
Expand Down
1 change: 0 additions & 1 deletion ibis/backends/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def test_isnan_isinf(
L(5.5).round(),
6.0,
id='round',
marks=pytest.mark.notimpl(["mssql"]),
),
param(
L(5.556).round(2),
Expand Down

0 comments on commit 52a60ce

Please sign in to comment.