Skip to content
Merged
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
51 changes: 51 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q51.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% include 'header.sql.jinja' %}

-- start query 1 in stream 0 using template query51.tpl and seed 1819994127
$web_v1 = (
select
web_sales.ws_item_sk item_sk, date_dim.d_date as d_date,
sum(sum(ws_sales_price))
over (partition by web_sales.ws_item_sk order by date_dim.d_date rows between unbounded preceding and current row) cume_sales
from {{web_sales}} as web_sales
cross join
{{date_dim}} as date_dim
where ws_sold_date_sk=d_date_sk
and d_month_seq between 1214 and 1214+11
and ws_item_sk is not NULL
group by web_sales.ws_item_sk, date_dim.d_date);

$store_v1 = (
select
store_sales.ss_item_sk item_sk, date_dim.d_date as d_date,
sum(sum(ss_sales_price))
over (partition by store_sales.ss_item_sk order by date_dim.d_date rows between unbounded preceding and current row) cume_sales
from {{store_sales}} as store_sales
cross join
{{date_dim}} as date_dim
where ss_sold_date_sk=d_date_sk
and d_month_seq between 1214 and 1214+11
and ss_item_sk is not NULL
group by store_sales.ss_item_sk, date_dim.d_date);

select *
from (select item_sk
,d_date
,web_sales
,store_sales
,max(web_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
,max(store_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
,case when web.d_date is not null then web.d_date else store.d_date end d_date
,web.cume_sales web_sales
,store.cume_sales store_sales
from $web_v1 as web full outer join $store_v1 as store on (web.item_sk = store.item_sk
and web.d_date = store.d_date)
)x )y
where web_cumulative > store_cumulative
order by item_sk
,d_date
limit 100;

-- end query 1 in stream 0 using template query51.tpl
26 changes: 26 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q52.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% include 'header.sql.jinja' %}

-- start query 1 in stream 0 using template query52.tpl and seed 1819994127
select dt.d_year
,item.i_brand_id brand_id
,item.i_brand brand
,sum(ss_ext_sales_price) ext_price
from {{date_dim}} dt
cross join
{{store_sales}} as store_sales
cross join
{{item}} as item
where dt.d_date_sk = store_sales.ss_sold_date_sk
and store_sales.ss_item_sk = item.i_item_sk
and item.i_manager_id = 1
and dt.d_moy=12
and dt.d_year=2000
group by dt.d_year
,item.i_brand
,item.i_brand_id
order by dt.d_year
,ext_price desc
,brand_id
limit 100 ;

-- end query 1 in stream 0 using template query52.tpl
33 changes: 33 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q53.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% include 'header.sql.jinja' %}

-- start query 1 in stream 0 using template query53.tpl and seed 1819994127
select * from
(select item.i_manufact_id as i_manufact_id,
sum(ss_sales_price) sum_sales,
avg(sum(ss_sales_price)) over (partition by item.i_manufact_id) avg_quarterly_sales
from {{item}} as item
cross join {{store_sales}} as store_sales
cross join {{date_dim}} as date_dim
cross join {{store}} as store
where ss_item_sk = i_item_sk and
ss_sold_date_sk = d_date_sk and
ss_store_sk = s_store_sk and
d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
((i_category in ('Books','Children','Electronics') and
i_class in ('personal','portable','reference','self-help') and
i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
'exportiunivamalg #9','scholaramalgamalg #9'))
or(i_category in ('Women','Music','Men') and
i_class in ('accessories','classical','fragrances','pants') and
i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
'importoamalg #1')))
group by item.i_manufact_id, date_dim.d_qoy ) tmp1
where case when avg_quarterly_sales > 0
then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales
else null end > 0.1
order by avg_quarterly_sales,
sum_sales,
i_manufact_id
limit 100;

-- end query 1 in stream 0 using template query53.tpl
71 changes: 71 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q54.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{% include 'header.sql.jinja' %}

-- start query 1 in stream 0 using template query54.tpl and seed 1930872976
$d_month_seq_begin = (select distinct d_month_seq+1
from {{date_dim}} as date_dim where d_year = 2000 and d_moy = 2);
$d_month_seq_end = (select distinct d_month_seq+3
from {{date_dim}} as date_dim where d_year = 2000 and d_moy = 2);

$my_customers = (
select distinct c_customer_sk
, c_current_addr_sk
from
( select cs_sold_date_sk sold_date_sk,
cs_bill_customer_sk customer_sk,
cs_item_sk item_sk
from {{catalog_sales}} as catalog_sales
union all
select ws_sold_date_sk sold_date_sk,
ws_bill_customer_sk customer_sk,
ws_item_sk item_sk
from {{web_sales}} as web_sales
) cs_or_ws_sales
cross join
{{item}} as item
cross join
{{date_dim}} as date_dim
cross join
{{customer}} as customer
where sold_date_sk = d_date_sk
and item_sk = i_item_sk
and i_category = 'Books'
and i_class = 'business'
and c_customer_sk = cs_or_ws_sales.customer_sk
and d_moy = 2
and d_year = 2000
);

$my_revenue = (
select my_customers.c_customer_sk,
sum(ss_ext_sales_price) as revenue
from $my_customers as my_customers
cross join
{{store_sales}} as store_sales
cross join
{{customer_address}} as customer_address
cross join
{{store}} as store
cross join
{{date_dim}} as date_dim
where my_customers.c_current_addr_sk = customer_address.ca_address_sk
and ca_county = s_county
and ca_state = s_state
and ss_sold_date_sk = d_date_sk
and c_customer_sk = ss_customer_sk
and d_month_seq between $d_month_seq_begin
and $d_month_seq_end
group by my_customers.c_customer_sk
);

$segments =
(select cast((revenue/50) as int) as segment
from $my_revenue
);

select segment, count(*) as num_customers, segment*50 as segment_base
from $segments
group by segment
order by segment, num_customers
limit 100;

-- end query 1 in stream 0 using template query54.tpl
18 changes: 18 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q55.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% include 'header.sql.jinja' %}

-- start query 1 in stream 0 using template query55.tpl and seed 2031708268
select item.i_brand_id brand_id, item.i_brand brand,
sum(ss_ext_sales_price) ext_price
from {{date_dim}} as date_dim
cross join {{store_sales}} as store_sales
cross join {{item}} as item
where d_date_sk = ss_sold_date_sk
and ss_item_sk = i_item_sk
and i_manager_id=13
and d_moy=11
and d_year=1999
group by item.i_brand, item.i_brand_id
order by ext_price desc, brand_id
limit 100 ;

-- end query 1 in stream 0 using template query55.tpl
4 changes: 4 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q56.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% include 'header.sql.jinja' %}

-- TODO: where is it?
select 1;
54 changes: 54 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q57.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% include 'header.sql.jinja' %}

-- NB: Subquerys
$v1 = (
select item.i_category i_category, item.i_brand i_brand,
call_center.cc_name cc_name,
date_dim.d_year d_year, date_dim.d_moy d_moy,
sum(cs_sales_price) sum_sales,
avg(sum(cs_sales_price)) over
(partition by item.i_category, item.i_brand,
call_center.cc_name, date_dim.d_year)
avg_monthly_sales,
rank() over
(partition by item.i_category, item.i_brand,
call_center.cc_name
order by date_dim.d_year, date_dim.d_moy) rn
from {{item}} as item
cross join {{catalog_sales}} as catalog_sales
cross join {{date_dim}} as date_dim
cross join {{call_center}} as call_center
where cs_item_sk = i_item_sk and
cs_sold_date_sk = d_date_sk and
cc_call_center_sk= cs_call_center_sk and
(
d_year = 1999 or
( d_year = 1999-1 and d_moy =12) or
( d_year = 1999+1 and d_moy =1)
)
group by item.i_category, item.i_brand,
call_center.cc_name , date_dim.d_year, date_dim.d_moy);
$v2 = (
select v1.i_category i_category, v1.i_brand i_brand
,v1.d_year d_year, v1.d_moy d_moy
,v1.avg_monthly_sales avg_monthly_sales
,v1.sum_sales sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
from $v1 v1 cross join $v1 v1_lag cross join $v1 v1_lead
where v1.i_category = v1_lag.i_category and
v1.i_category = v1_lead.i_category and
v1.i_brand = v1_lag.i_brand and
v1.i_brand = v1_lead.i_brand and
v1. cc_name = v1_lag. cc_name and
v1. cc_name = v1_lead. cc_name and
v1.rn = v1_lag.rn + 1 and
v1.rn = v1_lead.rn - 1);
-- start query 1 in stream 0 using template query57.tpl and seed 2031708268
select *
from $v2
where d_year = 1999 and
avg_monthly_sales > 0 and
case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
order by sum_sales - avg_monthly_sales, avg_monthly_sales
limit 100;

-- end query 1 in stream 0 using template query57.tpl
65 changes: 65 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q58.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% include 'header.sql.jinja' %}

-- NB: Subquerys
$week_seq = (select d_week_seq
from {{date_dim}} as date_dim
where d_date = '1998-02-21');
$ss_items =
(select item.i_item_id item_id
,sum(ss_ext_sales_price) ss_item_rev
from {{store_sales}} as store_sales
cross join {{item}} as item
cross join {{date_dim}} as date_dim
where ss_item_sk = i_item_sk
and d_date in (select d_date
from {{date_dim}} as date_dim
where d_week_seq = $week_seq)
and ss_sold_date_sk = d_date_sk
group by item.i_item_id);
$cs_items =
(select item.i_item_id item_id
,sum(cs_ext_sales_price) cs_item_rev
from {{catalog_sales}} as catalog_sales
cross join {{item}} as item
cross join {{date_dim}} as date_dim
where cs_item_sk = i_item_sk
and d_date in (select d_date
from {{date_dim}} as date_dim
where d_week_seq = $week_seq)
and cs_sold_date_sk = d_date_sk
group by item.i_item_id);
$ws_items =
(select item.i_item_id item_id
,sum(ws_ext_sales_price) ws_item_rev
from {{web_sales}} as web_sales
cross join {{item}} as item
cross join {{date_dim}} as date_dim
where ws_item_sk = i_item_sk
and d_date in (select d_date
from {{date_dim}} as date_dim
where d_week_seq =$week_seq)
and ws_sold_date_sk = d_date_sk
group by item.i_item_id);
-- start query 1 in stream 0 using template query58.tpl and seed 1819994127
select ss_items.item_id
,ss_item_rev
,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev
,cs_item_rev
,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev
,ws_item_rev
,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev
,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
from $ss_items ss_items cross join $cs_items cs_items cross join $ws_items ws_items
where ss_items.item_id=cs_items.item_id
and ss_items.item_id=ws_items.item_id
and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
order by item_id
,ss_item_rev
limit 100;

-- end query 1 in stream 0 using template query58.tpl
48 changes: 48 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q59.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% include 'header.sql.jinja' %}

-- NB: Subquerys
$wss =
(select date_dim.d_week_seq d_week_seq,
store_sales.ss_store_sk ss_store_sk,
sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales,
sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
from {{store_sales}} as store_sales
cross join {{date_dim}} as date_dim
where d_date_sk = ss_sold_date_sk
group by date_dim.d_week_seq,store_sales.ss_store_sk
);
-- start query 1 in stream 0 using template query59.tpl and seed 1819994127
select s_store_name1,s_store_id1,d_week_seq1
,sun_sales1/sun_sales2,mon_sales1/mon_sales2
,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2
,fri_sales1/fri_sales2,sat_sales1/sat_sales2
from
(select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
,s_store_id s_store_id1,sun_sales sun_sales1
,mon_sales mon_sales1,tue_sales tue_sales1
,wed_sales wed_sales1,thu_sales thu_sales1
,fri_sales fri_sales1,sat_sales sat_sales1
from $wss wss cross join {{store}} as store cross join {{date_dim}} d
where d.d_week_seq = wss.d_week_seq and
ss_store_sk = s_store_sk and
d_month_seq between 1205 and 1205 + 11) y cross join
(select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
,s_store_id s_store_id2,sun_sales sun_sales2
,mon_sales mon_sales2,tue_sales tue_sales2
,wed_sales wed_sales2,thu_sales thu_sales2
,fri_sales fri_sales2,sat_sales sat_sales2
from $wss wss cross join {{store}} as store cross join {{date_dim}} d
where d.d_week_seq = wss.d_week_seq and
ss_store_sk = s_store_sk and
d_month_seq between 1205+ 12 and 1205 + 23) x
where s_store_id1=s_store_id2
and d_week_seq1=d_week_seq2-52
order by s_store_name1,s_store_id1,d_week_seq1
limit 100;

-- end query 1 in stream 0 using template query59.tpl
Loading