Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit fee9ffe

Browse files
committed
refactor: fix notnull op with bracket
1 parent e91536c commit fee9ffe

File tree

4 files changed

+16
-5
lines changed
  • bigframes/core/compile/sqlglot/expressions
  • tests/unit/core/compile/sqlglot
    • aggregations/snapshots/test_unary_compiler/test_qcut
    • expressions/snapshots/test_generic_ops/test_notnull
    • snapshots/test_compile_window/test_compile_window_w_groupby_rolling

4 files changed

+16
-5
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def _(expr: TypedExpr, op: ops.MapOp) -> sge.Expression:
125125

126126
@register_unary_op(ops.notnull_op)
127127
def _(expr: TypedExpr) -> sge.Expression:
128-
return sge.Not(this=sge.Is(this=expr.expr, expression=sge.Null()))
128+
return sge.Is(
129+
this=sge.paren(expr.expr, copy=False),
130+
expression=sg.not_(sge.Null(), copy=False),
131+
)
129132

130133

131134
@register_ternary_op(ops.where_op)

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_qcut/out.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ WITH `bfcte_0` AS (
66
), `bfcte_1` AS (
77
SELECT
88
*,
9-
NOT `int64_col` IS NULL AS `bfcol_4`
9+
(
10+
`int64_col`
11+
) IS NOT NULL AS `bfcol_4`
1012
FROM `bfcte_0`
1113
), `bfcte_2` AS (
1214
SELECT
@@ -28,7 +30,9 @@ WITH `bfcte_0` AS (
2830
), `bfcte_4` AS (
2931
SELECT
3032
*,
31-
NOT `int64_col` IS NULL AS `bfcol_10`
33+
(
34+
`int64_col`
35+
) IS NOT NULL AS `bfcol_10`
3236
FROM `bfcte_3`
3337
), `bfcte_5` AS (
3438
SELECT

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ WITH `bfcte_0` AS (
55
), `bfcte_1` AS (
66
SELECT
77
*,
8-
NOT `float64_col` IS NULL AS `bfcol_1`
8+
(
9+
`float64_col`
10+
) IS NOT NULL AS `bfcol_1`
911
FROM `bfcte_0`
1012
)
1113
SELECT

tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ WITH `bfcte_0` AS (
1717
*
1818
FROM `bfcte_1`
1919
WHERE
20-
NOT `bfcol_9` IS NULL
20+
(
21+
`bfcol_9`
22+
) IS NOT NULL
2123
), `bfcte_3` AS (
2224
SELECT
2325
*,

0 commit comments

Comments
 (0)