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

Commit d4ac766

Browse files
committed
test: rewrite empty aggregate projection test to test Ibis compiler directly
1 parent 05805aa commit d4ac766

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/system/small/test_dataframe.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,9 +6285,14 @@ def test_agg_with_dict_containing_non_existing_col_raise_key_error(scalars_dfs):
62856285
bf_df.agg(agg_funcs)
62866286

62876287

6288-
def test_dataframe_count_empty_selection_succeeds(session):
6289-
# Tests that aggregate ops on empty selections don't trigger invalid empty SELECT syntax
6290-
df = session.read_gbq("SELECT 1 AS int_col")
6291-
empty_df = df[[]]
6292-
count_series = empty_df.count().to_pandas()
6293-
assert len(count_series) == 0
6288+
def test_empty_agg_projection_succeeds():
6289+
# Tests that the compiler generates a SELECT 1 fallback for empty aggregations,
6290+
# protecting against BigQuery syntax errors when both groups and metrics are empty.
6291+
import third_party.bigframes_vendored.ibis.backends.sql.compilers.bigquery as bq
6292+
import third_party.bigframes_vendored.sqlglot as sg
6293+
6294+
compiler = bq.BigQueryCompiler()
6295+
res = compiler.visit_Aggregate(
6296+
"op", parent=sg.table("parent_table"), groups=[], metrics=[]
6297+
)
6298+
assert "SELECT 1" in res.sql()

0 commit comments

Comments
 (0)