Skip to content

Commit

Permalink
refactor(bigquery): remove nullifzero
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `nullifzero` is removed; use `nullif(0)` instead
  • Loading branch information
cpcloud authored and gforsyth committed Dec 19, 2023
1 parent 8be3c25 commit 8447b9a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 24 deletions.
5 changes: 2 additions & 3 deletions ibis/backends/clickhouse/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ def test_timestamp_truncate(con, unit, snapshot):


@pytest.mark.parametrize(("value", "expected"), [(0, None), (5.5, 5.5)])
def test_nullifzero(con, value, expected):
with pytest.warns(FutureWarning):
result = con.execute(L(value).nullifzero())
def test_nullif_zero(con, value, expected):
result = con.execute(L(value).nullif(0))
if expected is None:
assert pd.isnull(result)
else:
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/dask/tests/execution/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,8 @@ def test_boolean_aggregation(t, df, reduction):


@pytest.mark.parametrize("column", ["float64_with_zeros", "int64_with_zeros"])
def test_null_if_zero(t, df, column):
with pytest.warns(FutureWarning):
expr = t[column].nullifzero()
def test_nullif_zero(t, df, column):
expr = t[column].nullif(0)
result = expr.compile()
expected = df[column].replace(0, np.nan)
tm.assert_series_equal(result.compute(), expected.compute(), check_index=False)
Expand Down
5 changes: 1 addition & 4 deletions ibis/backends/impala/tests/test_unary_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ def table(mockcon):
param(lambda x: x.ln(), id="ln"),
param(lambda x: x.log2(), id="log2"),
param(lambda x: x.log10(), id="log10"),
param(
lambda x: pytest.warns(FutureWarning, lambda y: y.nullifzero(), x),
id="nullifzero",
),
param(lambda x: x.nullif(0), id="nullif_zero"),
param(lambda x: x.fillna(0), id="zero_ifnull"),
],
)
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/pandas/tests/execution/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ def test_boolean_aggregation(t, df, reduction):


@pytest.mark.parametrize("column", ["float64_with_zeros", "int64_with_zeros"])
def test_null_if_zero(t, df, column):
with pytest.warns(FutureWarning):
expr = t[column].nullifzero()
def test_nullif_zero(t, df, column):
expr = t[column].nullif(0)
result = expr.execute()
expected = df[column].replace(0, np.nan)
tm.assert_series_equal(result, expected)
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/postgres/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ def test_typeof(con, value, expected):


@pytest.mark.parametrize(("value", "expected"), [(0, None), (5.5, 5.5)])
def test_nullifzero(con, value, expected):
with pytest.warns(FutureWarning):
assert con.execute(L(value).nullifzero()) == expected
def test_nullif_zero(con, value, expected):
assert con.execute(L(value).nullif(0)) == expected


@pytest.mark.parametrize(("value", "expected"), [("foo_bar", 7), ("", 0)])
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/sqlite/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ def test_div_floordiv(con, expr, expected):


@pytest.mark.parametrize(("lit", "expected"), [(L(0), None), (L(5.5), 5.5)])
def test_nullifzero(con, lit, expected):
with pytest.warns(FutureWarning):
expr = lit.nullifzero()
def test_nullif_zero(con, lit, expected):
expr = lit.nullif(0)
assert con.execute(expr) == expected


Expand Down
5 changes: 0 additions & 5 deletions ibis/expr/types/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,6 @@ def sqrt(self) -> NumericValue:
"""
return ops.Sqrt(self).to_expr()

@util.deprecated(instead="use nullif(0)", as_of="7.0", removed_in="8.0")
def nullifzero(self) -> NumericValue:
"""DEPRECATED: Use `nullif(0)` instead."""
return self.nullif(0)

def acos(self) -> NumericValue:
"""Compute the arc cosine of `self`.
Expand Down

0 comments on commit 8447b9a

Please sign in to comment.