Skip to content

Commit 7164175

Browse files
committed
chore: tighten up test for empty group by
1 parent 66d6839 commit 7164175

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

ibis/backends/tests/test_aggregation.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import itertools
4+
import sqlite3
45
from datetime import date
56
from operator import methodcaller
67

@@ -20,7 +21,9 @@
2021
GoogleBadRequest,
2122
ImpalaHiveServer2Error,
2223
MySQLNotSupportedError,
24+
MySQLOperationalError,
2325
OracleDatabaseError,
26+
PolarsColumnNotFoundError,
2427
PolarsInvalidOperationError,
2528
PsycoPg2InternalError,
2629
Py4JError,
@@ -1750,6 +1753,10 @@ def grouping_set_table():
17501753
)
17511754

17521755

1756+
@pytest.mark.notyet(["sqlite"], raises=sqlite3.OperationalError)
1757+
@pytest.mark.notyet(["mysql"], raises=MySQLOperationalError)
1758+
@pytest.mark.notyet(["polars"], raises=PolarsColumnNotFoundError)
1759+
@pytest.mark.notyet(["druid"])
17531760
def test_cube(con, backend, grouping_set_table):
17541761
expr = (
17551762
grouping_set_table.group_by(ibis.cube("b"))
@@ -1763,6 +1770,10 @@ def test_cube(con, backend, grouping_set_table):
17631770
backend.assert_frame_equal(result, expected)
17641771

17651772

1773+
@pytest.mark.notyet(["sqlite"], raises=sqlite3.OperationalError)
1774+
@pytest.mark.notyet(["mysql"], raises=MySQLOperationalError)
1775+
@pytest.mark.notyet(["polars"], raises=PolarsColumnNotFoundError)
1776+
@pytest.mark.notyet(["druid"])
17661777
def test_rollup(con, backend, grouping_set_table):
17671778
expr = (
17681779
grouping_set_table.group_by(ibis.rollup("b", "c"))
@@ -1782,6 +1793,26 @@ def test_rollup(con, backend, grouping_set_table):
17821793
backend.assert_frame_equal(result, expected)
17831794

17841795

1796+
@pytest.mark.notyet(["sqlite"], raises=sqlite3.OperationalError)
1797+
@pytest.mark.notyet(["mysql"], raises=MySQLOperationalError)
1798+
@pytest.mark.notimpl(["polars"], raises=com.OperationNotDefinedError)
1799+
@pytest.mark.notyet(["druid"], raises=Exception)
1800+
@pytest.mark.notyet(
1801+
[
1802+
"exasol",
1803+
"oracle",
1804+
"clickhouse",
1805+
"datafusion",
1806+
"risingwave",
1807+
"mssql",
1808+
"pyspark",
1809+
"impala",
1810+
"snowflake",
1811+
"bigquery",
1812+
],
1813+
raises=AssertionError,
1814+
reason="returns empty for a grouping set on an empty table, which disagrees with half the backends",
1815+
)
17851816
def test_grouping_empty_table(con, backend):
17861817
# TODO(cpcloud): group_id doesn't allow string columns
17871818
t = ibis.memtable({"c1": []}, schema={"c1": "int"})
@@ -1791,5 +1822,8 @@ def test_grouping_empty_table(con, backend):
17911822
.order_by(s.first())
17921823
)
17931824
result = con.to_pandas(expr)
1794-
expected = pd.DataFrame({"c1": [None], "gid": [1]})
1795-
backend.assert_frame_equal(result, expected)
1825+
1826+
assert len(result) == 1
1827+
assert len(result.columns) == 2
1828+
assert pd.isnull(result.at[0, "c1"])
1829+
assert result.at[0, "gid"] == 1

0 commit comments

Comments
 (0)