Skip to content

Commit c4bc7f6

Browse files
committed
refactor: add paren to the invert op
1 parent c331dfe commit c4bc7f6

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

bigframes/core/compile/sqlglot/expressions/generic_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def _(expr: TypedExpr) -> sge.Expression:
7676
@register_unary_op(ops.invert_op)
7777
def _(expr: TypedExpr) -> sge.Expression:
7878
if expr.dtype == dtypes.BOOL_DTYPE:
79-
return sge.Not(this=expr.expr)
80-
return sge.BitwiseNot(this=expr.expr)
79+
return sge.Not(this=sge.paren(expr.expr))
80+
return sge.BitwiseNot(this=sge.paren(expr.expr))
8181

8282

8383
@register_unary_op(ops.isnull_op)

tests/system/small/engines/test_generic_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def test_engines_isin_op(scalars_array_value: array_value.ArrayValue, engine):
454454
assert_equivalence_execution(arr.node, REFERENCE_ENGINE, engine)
455455

456456

457-
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
457+
@pytest.mark.parametrize("engine", ["polars", "bq", "bq-sqlglot"], indirect=True)
458458
def test_engines_isin_op_nested_filter(
459459
scalars_array_value: array_value.ArrayValue, engine
460460
):

tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_invert/out.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ WITH `bfcte_0` AS (
77
), `bfcte_1` AS (
88
SELECT
99
*,
10-
~`bfcol_2` AS `bfcol_6`,
11-
~`bfcol_1` AS `bfcol_7`,
12-
NOT `bfcol_0` AS `bfcol_8`
10+
~(
11+
`bfcol_2`
12+
) AS `bfcol_6`,
13+
~(
14+
`bfcol_1`
15+
) AS `bfcol_7`,
16+
NOT (
17+
`bfcol_0`
18+
) AS `bfcol_8`
1319
FROM `bfcte_0`
1420
)
1521
SELECT

0 commit comments

Comments
 (0)