Skip to content

Commit

Permalink
test(tpcds): query 88 (#9973)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Aug 30, 2024
1 parent 9c95437 commit 4f85430
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion ibis/backends/tests/tpc/ds/test_queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import calendar as cal
from operator import itemgetter
from operator import ge, itemgetter, lt
from pathlib import Path

import pytest
Expand Down Expand Up @@ -4289,6 +4289,25 @@ def test_79(store_sales, date_dim, store, household_demographics, customer):
)


@tpc_test("ds")
@pytest.mark.xfail(raises=NotImplementedError, reason="requires rollup")
def test_80(
store_sales,
store_returns,
store,
catalog_sales,
catalog_returns,
catalog_page,
web_sales,
web_returns,
web_site,
date_dim,
item,
promotion,
):
raise NotImplementedError()


@pytest.mark.notyet(
["clickhouse"],
raises=ClickHouseDatabaseError,
Expand Down Expand Up @@ -4564,6 +4583,41 @@ def cust(sales, sold_date_sk, customer_sk):
).agg(num_cool=_.count())


@tpc_test("ds")
def test_88(store_sales, household_demographics, time_dim, store):
def s(hour, fn, minute):
if fn is ge:
name = f"h{hour:d}_{minute:d}_to_{hour + 1:d}"
else:
name = f"h{hour:d}_to_{hour:d}_{minute:d}"

return (
store_sales.join(household_demographics, [("ss_hdemo_sk", "hd_demo_sk")])
.join(time_dim, [("ss_sold_time_sk", "t_time_sk")])
.join(store, [("ss_store_sk", "s_store_sk")])
.filter(
_.t_hour == hour,
fn(_.t_minute, minute),
((_.hd_dep_count == 4) & (_.hd_vehicle_count <= 4 + 2))
| ((_.hd_dep_count == 2) & (_.hd_vehicle_count <= 2 + 2))
| ((_.hd_dep_count == 0) & (_.hd_vehicle_count <= 0 + 2)),
_.s_store_name == "ese",
)
.agg(_.count().name(name))
)

return (
s(8, ge, 30)
.cross_join(s(9, lt, 30))
.cross_join(s(9, ge, 30))
.cross_join(s(10, lt, 30))
.cross_join(s(10, ge, 30))
.cross_join(s(11, lt, 30))
.cross_join(s(11, ge, 30))
.cross_join(s(12, lt, 30))
)


@tpc_test("ds")
def test_89(item, store_sales, date_dim, store):
return (
Expand Down

0 comments on commit 4f85430

Please sign in to comment.