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

Commit 1473e27

Browse files
committed
add isin sql
1 parent 848828f commit 1473e27

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
SELECT
2+
`t2`.`bfuid_col_1` AS `rowindex`,
3+
EXISTS(
4+
SELECT
5+
1
6+
FROM (
7+
SELECT
8+
`t3`.`column_0`
9+
FROM (
10+
SELECT
11+
*
12+
FROM (
13+
SELECT
14+
*
15+
FROM UNNEST(ARRAY<STRUCT<`column_0` FLOAT64>>[STRUCT(314159.0), STRUCT(2.0), STRUCT(3.0), STRUCT(CAST(NULL AS FLOAT64))]) AS `column_0`
16+
) AS `t1`
17+
) AS `t3`
18+
GROUP BY
19+
1
20+
) AS `t4`
21+
WHERE
22+
(
23+
COALESCE(`t2`.`int64_col`, 0) = COALESCE(`t4`.`column_0`, 0)
24+
)
25+
AND (
26+
COALESCE(`t2`.`int64_col`, 1) = COALESCE(`t4`.`column_0`, 1)
27+
)
28+
) AS `int64_col`
29+
FROM (
30+
SELECT
31+
`t0`.`rowindex` AS `bfuid_col_1`,
32+
`t0`.`int64_col`
33+
FROM (
34+
SELECT
35+
`int64_col`,
36+
`rowindex`
37+
FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-26T20:51:00.718609')
38+
) AS `t0`
39+
) AS `t2`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pandas as pd
16+
import pytest
17+
18+
import bigframes
19+
import bigframes.pandas as bpd
20+
21+
pytest.importorskip("pytest_snapshot")
22+
23+
24+
def test_compile_isin(
25+
scalar_types_df: bpd.DataFrame, compiler_session: bigframes.Session, snapshot
26+
):
27+
data = [314159, 2.0, 3, pd.NA]
28+
s = bpd.Series(data, session=compiler_session)
29+
bf_isin = scalar_types_df["int64_col"].isin(s).to_frame()
30+
snapshot.assert_match(bf_isin.sql, "out.sql")

0 commit comments

Comments
 (0)