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

Commit 71c4ec8

Browse files
committed
test: update empty agg test style and imports
1 parent f34aba9 commit 71c4ec8

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tests/system/small/test_dataframe.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import typing
2020
from typing import Dict, List, Tuple
2121

22+
from bigframes_vendored.ibis.backends.sql.compilers import bigquery as bq_compiler
23+
import bigframes_vendored.sqlglot as sg
2224
import geopandas as gpd # type: ignore
2325
import numpy as np
2426
import pandas as pd
@@ -6298,18 +6300,13 @@ def test_agg_with_dict_containing_non_existing_col_raise_key_error(scalars_dfs):
62986300
bf_df.agg(agg_funcs)
62996301

63006302

6301-
def test_empty_agg_projection_succeeds():
6302-
# Tests that the compiler generates a SELECT 1 fallback for empty aggregations,
6303-
# protecting against BigQuery syntax errors when both groups and metrics are empty.
6304-
import importlib
6303+
def test_empty_aggregation_generates_constant_fallback():
6304+
# Given a BigQuery compiler and a parent table
6305+
compiler = bq_compiler.BigQueryCompiler()
6306+
parent_table = sg.table("parent_table")
63056307

6306-
bq = importlib.import_module(
6307-
"third_party.bigframes_vendored.ibis.backends.sql.compilers.bigquery"
6308-
)
6309-
sg = importlib.import_module("third_party.bigframes_vendored.sqlglot")
6308+
# When visiting an Aggregate operation with empty groups and metrics
6309+
res = compiler.visit_Aggregate("op", parent=parent_table, groups=[], metrics=[])
63106310

6311-
compiler = bq.BigQueryCompiler()
6312-
res = compiler.visit_Aggregate(
6313-
"op", parent=sg.table("parent_table"), groups=[], metrics=[]
6314-
)
6311+
# Then it should generate a SELECT 1 fallback to avoid BigQuery syntax errors
63156312
assert "SELECT 1" in res.sql()

0 commit comments

Comments
 (0)