Skip to content

Commit 83f3119

Browse files
fix isin behavior with left null
1 parent 1708e33 commit 83f3119

6 files changed

Lines changed: 19 additions & 15 deletions

File tree

packages/bigframes/bigframes/core/compile/sqlglot/sqlglot_ir.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,13 @@ def isin_join(
385385
)
386386
)
387387
else:
388-
new_column = sge.In(
389-
this=conditions[0].expr,
390-
expressions=[right._as_subquery()],
388+
new_column = sge.func(
389+
"COALESCE",
390+
sge.In(
391+
this=conditions[0].expr,
392+
expressions=[right._as_subquery()],
393+
),
394+
sql.literal(False, dtypes.BOOL_DTYPE),
391395
)
392396

393397
new_column = sge.Alias(

packages/bigframes/tests/unit/core/compile/sqlglot/snapshots/test_compile_isin/test_compile_isin_not_nullable/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ WITH `bfcte_0` AS (
2020
), `bfcte_4` AS (
2121
SELECT
2222
*,
23-
`bfcol_4` IN ((
23+
COALESCE(`bfcol_4` IN ((
2424
SELECT
2525
*
2626
FROM `bfcte_3`
27-
)) AS `bfcol_5`
27+
)), FALSE) AS `bfcol_5`
2828
FROM `bfcte_1`
2929
)
3030
SELECT

packages/bigframes/tests/unit/core/compile/sqlglot/tpch/snapshots/test_tpch/test_tpch_query/16/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ WITH `bfcte_0` AS (
5151
), `bfcte_6` AS (
5252
SELECT
5353
*,
54-
`bfcol_58` IN ((
54+
COALESCE(`bfcol_58` IN ((
5555
SELECT
5656
*
5757
FROM `bfcte_5`
58-
)) AS `bfcol_59`
58+
)), FALSE) AS `bfcol_59`
5959
FROM `bfcte_4`
6060
), `bfcte_7` AS (
6161
SELECT

packages/bigframes/tests/unit/core/compile/sqlglot/tpch/snapshots/test_tpch/test_tpch_query/18/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ WITH `bfcte_0` AS (
4444
), `bfcte_7` AS (
4545
SELECT
4646
*,
47-
`bfcol_4` IN ((
47+
COALESCE(`bfcol_4` IN ((
4848
SELECT
4949
*
5050
FROM `bfcte_6`
51-
)) AS `bfcol_14`
51+
)), FALSE) AS `bfcol_14`
5252
FROM `bfcte_2`
5353
), `bfcte_8` AS (
5454
SELECT

packages/bigframes/tests/unit/core/compile/sqlglot/tpch/snapshots/test_tpch/test_tpch_query/20/out.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ WITH `bfcte_0` AS (
8585
), `bfcte_10` AS (
8686
SELECT
8787
*,
88-
`bfcol_2` IN ((
88+
COALESCE(`bfcol_2` IN ((
8989
SELECT
9090
*
9191
FROM `bfcte_8`
92-
)) AS `bfcol_37`
92+
)), FALSE) AS `bfcol_37`
9393
FROM `bfcte_1`
9494
), `bfcte_11` AS (
9595
SELECT
@@ -127,11 +127,11 @@ WITH `bfcte_0` AS (
127127
), `bfcte_15` AS (
128128
SELECT
129129
*,
130-
`bfcol_41` IN ((
130+
COALESCE(`bfcol_41` IN ((
131131
SELECT
132132
*
133133
FROM `bfcte_14`
134-
)) AS `bfcol_62`
134+
)), FALSE) AS `bfcol_62`
135135
FROM `bfcte_7`
136136
)
137137
SELECT

packages/bigframes/tests/unit/core/compile/sqlglot/tpch/snapshots/test_tpch/test_tpch_query/22/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ WITH `bfcte_0` AS (
9292
), `bfcte_12` AS (
9393
SELECT
9494
*,
95-
`bfcol_61` IN ((
95+
COALESCE(`bfcol_61` IN ((
9696
SELECT
9797
*
9898
FROM `bfcte_6`
99-
)) AS `bfcol_64`
99+
)), FALSE) AS `bfcol_64`
100100
FROM `bfcte_11`
101101
), `bfcte_13` AS (
102102
SELECT

0 commit comments

Comments
 (0)