diff --git a/bigframes/core/compile/scalar_op_compiler.py b/bigframes/core/compile/scalar_op_compiler.py index 5c165fa1df..53a25d63ed 100644 --- a/bigframes/core/compile/scalar_op_compiler.py +++ b/bigframes/core/compile/scalar_op_compiler.py @@ -397,7 +397,7 @@ def expm1_op_impl(x: ibis_types.Value): @scalar_op_compiler.register_unary_op(ops.invert_op) def invert_op_impl(x: ibis_types.Value): - return typing.cast(ibis_types.NumericValue, x).negate() + return x.__invert__() ## String Operation diff --git a/tests/system/small/test_series.py b/tests/system/small/test_series.py index e350286940..13248b2e63 100644 --- a/tests/system/small/test_series.py +++ b/tests/system/small/test_series.py @@ -284,6 +284,21 @@ def test_abs(scalars_dfs, col_name): assert_series_equal(pd_result, bf_result) +@pytest.mark.parametrize( + ("col_name",), + ( + ("bool_col",), + ("int64_col",), + ), +) +def test_series_invert(scalars_dfs, col_name): + scalars_df, scalars_pandas_df = scalars_dfs + bf_result = (~scalars_df[col_name]).to_pandas() + pd_result = ~scalars_pandas_df[col_name] + + assert_series_equal(pd_result, bf_result) + + def test_fillna(scalars_dfs): scalars_df, scalars_pandas_df = scalars_dfs col_name = "string_col"