Skip to content

Commit

Permalink
test(tpcds): add test for query 79
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Aug 26, 2024
1 parent 9da3c9f commit aada0a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions ibis/backends/tests/tpc/ds/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

import ibis
from ibis import _, coalesce, cumulative_window, date, ifelse, null, rank, union
from ibis import literal as lit
from ibis import selectors as s
Expand Down Expand Up @@ -3208,3 +3209,40 @@ def test_63(item, store_sales, date_dim, store):
.order_by(_.i_manager_id, _.avg_monthly_sales, _.sum_sales)
.limit(100)
)


@tpc_test("ds")
def test_79(store_sales, date_dim, store, household_demographics, customer):
return (
store_sales.join(date_dim, [("ss_sold_date_sk", "d_date_sk")])
.join(store, [("ss_store_sk", "s_store_sk")])
.join(household_demographics, [("ss_hdemo_sk", "hd_demo_sk")])
.filter(
(_.hd_dep_count == 6) | (_.hd_vehicle_count > 2),
_.d_dow == 1,
_.d_year.between(1999, 1999 + 2),
_.s_number_employees.between(200, 295),
)
.group_by("ss_ticket_number", "ss_customer_sk", "ss_addr_sk", "s_city")
.agg(
amt=_.ss_coupon_amt.sum(),
profit=_.ss_net_profit.sum(),
)
.join(customer, [("ss_customer_sk", "c_customer_sk")])
.select(
"c_last_name",
"c_first_name",
_.s_city[:30].name("s_city_substr"),
"ss_ticket_number",
"amt",
"profit",
)
.order_by(
ibis.asc("c_last_name", nulls_first=True),
ibis.asc("c_first_name", nulls_first=True),
ibis.asc("s_city_substr", nulls_first=True),
ibis.asc("profit", nulls_first=True),
"ss_ticket_number",
)
.limit(100)
)
2 changes: 1 addition & 1 deletion ibis/backends/tests/tpc/queries/duckdb/ds/79.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT c_last_name,
c_first_name,
SUBSTRING(s_city,1,30),
SUBSTRING(s_city,1,30) AS s_city_substr,
ss_ticket_number,
amt,
profit
Expand Down

0 comments on commit aada0a8

Please sign in to comment.