Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions sql/core/src/test/resources/tpcds-v2.7.0/q10a.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- This is a new query in TPCDS v2.7
select
cd_gender,
cd_marital_status,
cd_education_status,
count(*) cnt1,
cd_purchase_estimate,
count(*) cnt2,
cd_credit_rating,
count(*) cnt3,
cd_dep_count,
count(*) cnt4,
cd_dep_employed_count,
count(*) cnt5,
cd_dep_college_count,
count(*) cnt6
from
customer c,customer_address ca,customer_demographics
where
c.c_current_addr_sk = ca.ca_address_sk
and ca_county in ('Walker County', 'Richland County', 'Gaines County', 'Douglas County', 'Dona Ana County')
and cd_demo_sk = c.c_current_cdemo_sk
and exists (
select *
from store_sales,date_dim
where c.c_customer_sk = ss_customer_sk
and ss_sold_date_sk = d_date_sk
and d_year = 2002
and d_moy between 4 and 4 + 3)
and exists (
select *
from (
select
ws_bill_customer_sk as customer_sk,
d_year,
d_moy
from web_sales, date_dim
where ws_sold_date_sk = d_date_sk
and d_year = 2002
and d_moy between 4 and 4 + 3
union all
select
cs_ship_customer_sk as customer_sk,
d_year,
d_moy
from catalog_sales, date_dim
where cs_sold_date_sk = d_date_sk
and d_year = 2002
and d_moy between 4 and 4 + 3) x
where c.c_customer_sk = customer_sk)
group by
cd_gender,
cd_marital_status,
cd_education_status,
cd_purchase_estimate,
cd_credit_rating,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
order by
cd_gender,
cd_marital_status,
cd_education_status,
cd_purchase_estimate,
cd_credit_rating,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
limit 100
84 changes: 84 additions & 0 deletions sql/core/src/test/resources/tpcds-v2.7.0/q11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
WITH year_total AS (
SELECT
c_customer_id customer_id,
c_first_name customer_first_name,
c_last_name customer_last_name,
c_preferred_cust_flag customer_preferred_cust_flag,
c_birth_country customer_birth_country,
c_login customer_login,
c_email_address customer_email_address,
d_year dyear,
sum(ss_ext_list_price - ss_ext_discount_amt) year_total,
's' sale_type
FROM customer, store_sales, date_dim
WHERE c_customer_sk = ss_customer_sk
AND ss_sold_date_sk = d_date_sk
GROUP BY c_customer_id
, c_first_name
, c_last_name
, d_year
, c_preferred_cust_flag
, c_birth_country
, c_login
, c_email_address
, d_year
UNION ALL
SELECT
c_customer_id customer_id,
c_first_name customer_first_name,
c_last_name customer_last_name,
c_preferred_cust_flag customer_preferred_cust_flag,
c_birth_country customer_birth_country,
c_login customer_login,
c_email_address customer_email_address,
d_year dyear,
sum(ws_ext_list_price - ws_ext_discount_amt) year_total,
'w' sale_type
FROM customer, web_sales, date_dim
WHERE c_customer_sk = ws_bill_customer_sk
AND ws_sold_date_sk = d_date_sk
GROUP BY
c_customer_id, c_first_name, c_last_name, c_preferred_cust_flag, c_birth_country,
c_login, c_email_address, d_year)
SELECT
-- select list of q11 in TPCDS v1.4 is below:
-- t_s_secyear.customer_preferred_cust_flag
t_s_secyear.customer_id,
t_s_secyear.customer_first_name,
t_s_secyear.customer_last_name,
t_s_secyear.customer_email_address
FROM year_total t_s_firstyear
, year_total t_s_secyear
, year_total t_w_firstyear
, year_total t_w_secyear
WHERE t_s_secyear.customer_id = t_s_firstyear.customer_id
AND t_s_firstyear.customer_id = t_w_secyear.customer_id
AND t_s_firstyear.customer_id = t_w_firstyear.customer_id
AND t_s_firstyear.sale_type = 's'
AND t_w_firstyear.sale_type = 'w'
AND t_s_secyear.sale_type = 's'
AND t_w_secyear.sale_type = 'w'
AND t_s_firstyear.dyear = 2001
AND t_s_secyear.dyear = 2001 + 1
AND t_w_firstyear.dyear = 2001
AND t_w_secyear.dyear = 2001 + 1
AND t_s_firstyear.year_total > 0
AND t_w_firstyear.year_total > 0
AND CASE WHEN t_w_firstyear.year_total > 0
THEN t_w_secyear.year_total / t_w_firstyear.year_total
-- q11 in TPCDS v1.4 used NULL
-- ELSE NULL END
ELSE 0.0 END
> CASE WHEN t_s_firstyear.year_total > 0
THEN t_s_secyear.year_total / t_s_firstyear.year_total
-- q11 in TPCDS v1.4 used NULL
-- ELSE NULL END
ELSE 0.0 END
ORDER BY
-- order-by list of q11 in TPCDS v1.4 is below:
-- t_s_secyear.customer_preferred_cust_flag
t_s_secyear.customer_id,
t_s_secyear.customer_first_name,
t_s_secyear.customer_last_name,
t_s_secyear.customer_email_address
LIMIT 100
23 changes: 23 additions & 0 deletions sql/core/src/test/resources/tpcds-v2.7.0/q12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SELECT
i_item_id, -- This column did not exist in TPCDS v1.4
i_item_desc,
i_category,
i_class,
i_current_price,
sum(ws_ext_sales_price) AS itemrevenue,
sum(ws_ext_sales_price) * 100 / sum(sum(ws_ext_sales_price))
OVER
(PARTITION BY i_class) AS revenueratio
FROM
web_sales, item, date_dim
WHERE
ws_item_sk = i_item_sk
AND i_category IN ('Sports', 'Books', 'Home')
AND ws_sold_date_sk = d_date_sk
AND d_date BETWEEN cast('1999-02-22' AS DATE)
AND (cast('1999-02-22' AS DATE) + INTERVAL 30 days)
GROUP BY
i_item_id, i_item_desc, i_category, i_class, i_current_price
ORDER BY
i_category, i_class, i_item_id, i_item_desc, revenueratio
LIMIT 100
135 changes: 135 additions & 0 deletions sql/core/src/test/resources/tpcds-v2.7.0/q14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
-- This query is the alternative form of sql/core/src/test/resources/tpcds/q14a.sql
with cross_items as (
select
i_item_sk ss_item_sk
from item, (
select
iss.i_brand_id brand_id,
iss.i_class_id class_id,
iss.i_category_id category_id
from
store_sales, item iss, date_dim d1
where
ss_item_sk = iss.i_item_sk
and ss_sold_date_sk = d1.d_date_sk
and d1.d_year between 1998 AND 1998 + 2
intersect
select
ics.i_brand_id,
ics.i_class_id,
ics.i_category_id
from
catalog_sales, item ics, date_dim d2
where
cs_item_sk = ics.i_item_sk
and cs_sold_date_sk = d2.d_date_sk
and d2.d_year between 1998 AND 1998 + 2
intersect
select
iws.i_brand_id,
iws.i_class_id,
iws.i_category_id
from
web_sales, item iws, date_dim d3
where
ws_item_sk = iws.i_item_sk
and ws_sold_date_sk = d3.d_date_sk
and d3.d_year between 1998 AND 1998 + 2) x
where
i_brand_id = brand_id
and i_class_id = class_id
and i_category_id = category_id),
avg_sales as (
select
avg(quantity*list_price) average_sales
from (
select
ss_quantity quantity,
ss_list_price list_price
from
store_sales, date_dim
where
ss_sold_date_sk = d_date_sk
and d_year between 1998 and 1998 + 2
union all
select
cs_quantity quantity,
cs_list_price list_price
from
catalog_sales, date_dim
where
cs_sold_date_sk = d_date_sk
and d_year between 1998 and 1998 + 2
union all
select
ws_quantity quantity,
ws_list_price list_price
from
web_sales, date_dim
where
ws_sold_date_sk = d_date_sk
and d_year between 1998 and 1998 + 2) x)
select
*
from (
select
'store' channel,
i_brand_id,
i_class_id,
i_category_id,
sum(ss_quantity * ss_list_price) sales,
count(*) number_sales
from
store_sales, item, date_dim
where
ss_item_sk in (select ss_item_sk from cross_items)
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_week_seq = (
select d_week_seq
from date_dim
where d_year = 1998 + 1
and d_moy = 12
and d_dom = 16)
group by
i_brand_id,
i_class_id,
i_category_id
having
sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year,
(
select
'store' channel,
i_brand_id,
i_class_id,
i_category_id,
sum(ss_quantity * ss_list_price) sales,
count(*) number_sales
from
store_sales, item, date_dim
where
ss_item_sk in (select ss_item_sk from cross_items)
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_week_seq = (
select d_week_seq
from date_dim
where d_year = 1998
and d_moy = 12
and d_dom = 16)
group by
i_brand_id,
i_class_id,
i_category_id
having
sum(ss_quantity * ss_list_price) > (select average_sales from avg_sales)) last_year
where
this_year.i_brand_id = last_year.i_brand_id
and this_year.i_class_id = last_year.i_class_id
and this_year.i_category_id = last_year.i_category_id
order by
this_year.channel,
this_year.i_brand_id,
this_year.i_class_id,
this_year.i_category_id
limit 100
Loading