File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
tests/unit/core/compile/sqlglot
snapshots/test_compile_window/test_compile_window Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ SELECT
2+ ` rowindex` AS ` rowindex` ,
3+ ` int64_col` AS ` int64_col`
4+ FROM
5+ (SELECT
6+ ` t1` .` rowindex` ,
7+ CASE
8+ WHEN COALESCE(
9+ SUM (CAST((
10+ ` t1` .` int64_col`
11+ ) IS NOT NULL AS INT64)) OVER (
12+ ORDER BY ` t1` .` rowindex` IS NULL ASC , ` t1` .` rowindex` ASC
13+ ROWS BETWEEN 2 preceding AND CURRENT ROW
14+ ),
15+ 0
16+ ) < 3
17+ THEN NULL
18+ ELSE COALESCE(
19+ SUM (` t1` .` int64_col` ) OVER (
20+ ORDER BY ` t1` .` rowindex` IS NULL ASC , ` t1` .` rowindex` ASC
21+ ROWS BETWEEN 2 preceding AND CURRENT ROW
22+ ),
23+ 0
24+ )
25+ END AS ` int64_col`
26+ FROM (
27+ SELECT
28+ ` t0` .` int64_col` ,
29+ ` t0` .` rowindex`
30+ FROM ` bigframes-dev.sqlglot_test.scalar_types` AS ` t0`
31+ ) AS ` t1` )
32+ ORDER BY ` rowindex` ASC NULLS LAST
Original file line number Diff line number Diff line change 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 pytest
16+
17+ import bigframes .pandas as bpd
18+
19+ pytest .importorskip ("pytest_snapshot" )
20+
21+
22+ def test_compile_window (scalar_types_df : bpd .DataFrame , snapshot ):
23+ result = scalar_types_df [["int64_col" ]].sort_index ().rolling (window = 3 ).sum ()
24+ snapshot .assert_match (result .sql , "out.sql" )
You can’t perform that action at this time.
0 commit comments