Skip to content

Commit

Permalink
test(tpcds): query 81 (#9971)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Aug 30, 2024
1 parent ec9a1bc commit 9c95437
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions ibis/backends/tests/tpc/ds/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,12 @@ def agg_sales_net_by_month(sales, ns, sales_expr, net_expr):
)


@pytest.mark.xfail(raises=NotImplementedError, reason="requires rollup")
@tpc_test("ds")
def test_67(store_sales, date_dim, store, item):
raise NotImplementedError()


@tpc_test("ds")
def test_68(
store_sales, date_dim, store, household_demographics, customer_address, customer
Expand Down Expand Up @@ -4283,6 +4289,54 @@ def test_79(store_sales, date_dim, store, household_demographics, customer):
)


@pytest.mark.notyet(
["clickhouse"],
raises=ClickHouseDatabaseError,
reason="correlated subqueries don't exist in clickhouse",
)
@tpc_test("ds")
def test_81(catalog_returns, date_dim, customer_address, customer):
customer_total_return = (
catalog_returns.join(date_dim, [("cr_returned_date_sk", "d_date_sk")])
.join(customer_address, [("cr_returning_addr_sk", "ca_address_sk")])
.filter(_.d_year == 2000)
.group_by(ctr_customer_sk=_.cr_returning_customer_sk, ctr_state=_.ca_state)
.agg(ctr_total_return=_.cr_return_amt_inc_tax.sum())
)
ctr2 = customer_total_return.view()
return (
customer_total_return.join(customer, [("ctr_customer_sk", "c_customer_sk")])
.join(customer_address, [("c_current_addr_sk", "ca_address_sk")])
.filter(
lambda ctr1: ctr1.ctr_total_return
> (
ctr2.filter(ctr1.ctr_state == _.ctr_state).ctr_total_return.mean() * 1.2
).as_scalar(),
_.ca_state == "GA",
)
.select(
_.c_customer_id,
_.c_salutation,
_.c_first_name,
_.c_last_name,
_.ca_street_number,
_.ca_street_name,
_.ca_street_type,
_.ca_suite_number,
_.ca_city,
_.ca_county,
_.ca_state,
_.ca_zip,
_.ca_country,
_.ca_gmt_offset,
_.ca_location_type,
_.ctr_total_return,
)
.order_by(s.all())
.limit(100)
)


@tpc_test("ds", result_is_empty=True)
def test_82(item, inventory, date_dim, store_sales):
return (
Expand Down

0 comments on commit 9c95437

Please sign in to comment.