diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q51.sql b/ydb/library/benchmarks/queries/tpcds/yql/q51.sql new file mode 100644 index 000000000000..b474954e32df --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q51.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q52.sql b/ydb/library/benchmarks/queries/tpcds/yql/q52.sql new file mode 100644 index 000000000000..9363efa542f0 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q52.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q53.sql b/ydb/library/benchmarks/queries/tpcds/yql/q53.sql new file mode 100644 index 000000000000..c0b6c58f6286 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q53.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q54.sql b/ydb/library/benchmarks/queries/tpcds/yql/q54.sql new file mode 100644 index 000000000000..1607f15941f8 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q54.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q55.sql b/ydb/library/benchmarks/queries/tpcds/yql/q55.sql new file mode 100644 index 000000000000..62996dc695ed --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q55.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q56.sql b/ydb/library/benchmarks/queries/tpcds/yql/q56.sql new file mode 100644 index 000000000000..64aba211c0c5 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q56.sql @@ -0,0 +1,4 @@ +{% include 'header.sql.jinja' %} + +-- TODO: where is it? +select 1; diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q57.sql b/ydb/library/benchmarks/queries/tpcds/yql/q57.sql new file mode 100644 index 000000000000..a4aeaf0b8f01 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q57.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q58.sql b/ydb/library/benchmarks/queries/tpcds/yql/q58.sql new file mode 100644 index 000000000000..c1dbee868069 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q58.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q59.sql b/ydb/library/benchmarks/queries/tpcds/yql/q59.sql new file mode 100644 index 000000000000..14905ed01588 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q59.sql @@ -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 diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q60.sql b/ydb/library/benchmarks/queries/tpcds/yql/q60.sql new file mode 100644 index 000000000000..168940f46d64 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q60.sql @@ -0,0 +1,81 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +$ss = ( + select + item.i_item_id i_item_id,sum(ss_ext_sales_price) total_sales + from + {{store_sales}} as store_sales cross join + {{date_dim}} as date_dim cross join + {{customer_address}} as customer_address cross join + {{item}} as item + where + i_item_id in (select + i_item_id +from + {{item}} as item +where i_category in ('Children')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by item.i_item_id); +$cs = ( + select + item.i_item_id i_item_id,sum(cs_ext_sales_price) total_sales + from + {{catalog_sales}} as catalog_sales cross join + {{date_dim}} as date_dim cross join + {{customer_address}} as customer_address cross join + {{item}} as item + where + i_item_id in (select + i_item_id +from + {{item}} as item +where i_category in ('Children')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by item.i_item_id); + $ws = ( + select + item.i_item_id i_item_id,sum(ws_ext_sales_price) total_sales + from + {{web_sales}} as web_sales cross join + {{date_dim}} as date_dim cross join + {{customer_address}} as customer_address cross join + {{item}} as item + where + i_item_id in (select + i_item_id +from + {{item}} as item +where i_category in ('Children')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by item.i_item_id); +-- start query 1 in stream 0 using template query60.tpl and seed 1930872976 + select + i_item_id +,sum(total_sales) total_sales + from (select * from $ss + union all + select * from $cs + union all + select * from $ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100; + +-- end query 1 in stream 0 using template query60.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q61.sql b/ydb/library/benchmarks/queries/tpcds/yql/q61.sql new file mode 100644 index 000000000000..a6044292cd90 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q61.sql @@ -0,0 +1,47 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query61.tpl and seed 1930872976 +select promotions,total,cast(promotions as float)/cast(total as float)*100 +from + (select sum(ss_ext_sales_price) promotions + from {{store_sales}} as store_sales + cross join {{store}} as store + cross join {{promotion}} as promotion + cross join {{date_dim}} as date_dim + cross join {{customer}} as customer + cross join {{customer_address}} as customer_address + cross join {{item}} as item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -6 + and d_year = 2001 + and d_moy = 12) promotional_sales cross join + (select sum(ss_ext_sales_price) total + from {{store_sales}} as store_sales + cross join {{store}} as store + cross join {{date_dim}} as date_dim + cross join {{customer}} as customer + cross join {{customer_address}} as customer_address + cross join {{item}} as item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6 + and i_category = 'Sports' + and s_gmt_offset = -6 + and d_year = 2001 + and d_moy = 12) all_sales +order by promotions, total +limit 100; + +-- end query 1 in stream 0 using template query61.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q62.sql b/ydb/library/benchmarks/queries/tpcds/yql/q62.sql new file mode 100644 index 000000000000..b0ec41f4d85a --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q62.sql @@ -0,0 +1,38 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query62.tpl and seed 1819994127 +select + bla + ,ship_mode.sm_type + ,web_site.web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as `30 days` + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as `31-60 days` + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as `61-90 days` + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as `91-120 days` + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as `>120 days` +from + {{web_sales}} as web_sales + cross join {{warehouse}} as warehouse + cross join {{ship_mode}} as ship_mode + cross join {{web_site}} as web_site + cross join {{date_dim}} as date_dim +where + d_month_seq between 1215 and 1215 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substring(cast(w_warehouse_name as string),1,20) as bla + ,ship_mode.sm_type + ,web_site.web_name +order by bla + ,ship_mode.sm_type + ,web_site.web_name +limit 100; + +-- end query 1 in stream 0 using template query62.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q63.sql b/ydb/library/benchmarks/queries/tpcds/yql/q63.sql new file mode 100644 index 000000000000..a904061a0ccd --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q63.sql @@ -0,0 +1,32 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query63.tpl and seed 1819994127 +select * +from (select item.i_manager_id i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by item.i_manager_id) avg_monthly_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 (1211,1211+1,1211+2,1211+3,1211+4,1211+5,1211+6,1211+7,1211+8,1211+9,1211+10,1211+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_manager_id, date_dim.d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100; + +-- end query 1 in stream 0 using template query63.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q64.sql b/ydb/library/benchmarks/queries/tpcds/yql/q64.sql new file mode 100644 index 000000000000..659db7d570da --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q64.sql @@ -0,0 +1,124 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +$cs_ui = + (select catalog_sales.cs_item_sk cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from {{catalog_sales}} as catalog_sales + cross join {{catalog_returns}} as catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by catalog_sales.cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)); +$cross_sales = + (select item.i_product_name product_name + ,item.i_item_sk item_sk + ,store.s_store_name store_name + ,store.s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM {{store_sales}} as store_sales + cross join {{store_returns}} as store_returns + cross join $cs_ui cs_ui + cross join {{date_dim}} d1 + cross join {{date_dim}} d2 + cross join {{date_dim}} d3 + cross join {{store}} as store + cross join {{customer}} as customer + cross join {{customer_demographics}} cd1 + cross join {{customer_demographics}} cd2 + cross join {{promotion}} as promotion + cross join {{household_demographics}} hd1 + cross join {{household_demographics}} hd2 + cross join {{customer_address}} ad1 + cross join {{customer_address}} ad2 + cross join {{income_band}} ib1 + cross join {{income_band}} ib2 + cross join {{item}} as item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('azure','gainsboro','misty','blush','hot','lemon') and + i_current_price between 80 and 80 + 10 and + i_current_price between 80 + 1 and 80 + 15 +group by item.i_product_name + ,item.i_item_sk + ,store.s_store_name + ,store.s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +); +-- start query 1 in stream 0 using template query64.tpl and seed 1220860970 +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from $cross_sales cs1 cross join $cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,s11 + ,s21; + +-- end query 1 in stream 0 using template query64.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q65.sql b/ydb/library/benchmarks/queries/tpcds/yql/q65.sql new file mode 100644 index 000000000000..a524e7d30a03 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q65.sql @@ -0,0 +1,35 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query65.tpl and seed 1819994127 +select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from {{store}} as store + cross join {{item}} as item cross join + (select ss_store_sk, avg(revenue) as ave + from + (select store_sales.ss_store_sk ss_store_sk, store_sales.ss_item_sk ss_item_sk, + sum(ss_sales_price) as revenue + 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 1186 and 1186+11 + group by store_sales.ss_store_sk, store_sales.ss_item_sk) sa + group by ss_store_sk) sb cross join + (select store_sales.ss_store_sk ss_store_sk, store_sales.ss_item_sk ss_item_sk, sum(ss_sales_price) as revenue + 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 1186 and 1186+11 + group by store_sales.ss_store_sk, store_sales.ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100; + +-- end query 1 in stream 0 using template query65.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q66.sql b/ydb/library/benchmarks/queries/tpcds/yql/q66.sql new file mode 100644 index 000000000000..1bb3a1037c7f --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q66.sql @@ -0,0 +1,223 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query66.tpl and seed 2042478054 +select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + warehouse.w_warehouse_name w_warehouse_name + ,warehouse.w_warehouse_sq_ft w_warehouse_sq_ft + ,warehouse.w_city w_city + ,warehouse.w_county w_county + ,warehouse.w_state w_state + ,warehouse.w_country w_country + ,'MSC' || ',' || 'GERMA' as ship_carriers + ,date_dim.d_year as year + ,sum(case when d_moy = 1 + then ws_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as dec_net + from + {{web_sales}} as web_sales + cross join {{warehouse}} as warehouse + cross join {{date_dim}} as date_dim + cross join {{time_dim}} as time_dim + cross join {{ship_mode}} as ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 9453 and 9453+28800 + and sm_carrier in ('MSC','GERMA') + group by + warehouse.w_warehouse_name + ,warehouse.w_warehouse_sq_ft + ,warehouse.w_city + ,warehouse.w_county + ,warehouse.w_state + ,warehouse.w_country + ,date_dim.d_year + union all + select + warehouse.w_warehouse_name w_warehouse_name + ,warehouse.w_warehouse_sq_ft w_warehouse_sq_ft + ,warehouse.w_city w_city + ,warehouse.w_county w_county + ,warehouse.w_state w_state + ,warehouse.w_country w_country + ,'MSC' || ',' || 'GERMA' as ship_carriers + ,date_dim.d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid_inc_ship * cs_quantity else 0 end) as dec_net + from + {{catalog_sales}} as catalog_sales + cross join {{warehouse}} as warehouse + cross join {{date_dim}} as date_dim + cross join {{time_dim}} as time_dim + cross join {{ship_mode}} as ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 9453 AND 9453+28800 + and sm_carrier in ('MSC','GERMA') + group by + warehouse.w_warehouse_name + ,warehouse.w_warehouse_sq_ft + ,warehouse.w_city + ,warehouse.w_county + ,warehouse.w_state + ,warehouse.w_country + ,date_dim.d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100; + +-- end query 1 in stream 0 using template query66.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q67.sql b/ydb/library/benchmarks/queries/tpcds/yql/q67.sql new file mode 100644 index 000000000000..b2266429ab5b --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q67.sql @@ -0,0 +1,47 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query67.tpl and seed 1819994127 +select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select item.i_category i_category + ,item.i_class i_class + ,item.i_brand i_brand + ,item.i_product_name i_product_name + ,date_dim.d_year d_year + ,date_dim.d_qoy d_qoy + ,date_dim.d_moy d_moy + ,store.s_store_id s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + cross join {{store}} as store + cross join {{item}} as item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1185 and 1185+11 + group by rollup(item.i_category, item.i_class, item.i_brand, item.i_product_name, date_dim.d_year, date_dim.d_qoy, date_dim.d_moy,store.s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100; + +-- end query 1 in stream 0 using template query67.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q68.sql b/ydb/library/benchmarks/queries/tpcds/yql/q68.sql new file mode 100644 index 000000000000..f0d283fb437f --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q68.sql @@ -0,0 +1,45 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query68.tpl and seed 803547492 +select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select store_sales.ss_ticket_number ss_ticket_number + ,store_sales.ss_customer_sk ss_customer_sk + ,customer_address.ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + cross join {{store}} as store + cross join {{household_demographics}} as household_demographics + cross join {{customer_address}} as customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 4 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_year in (1999,1999+1,1999+2) + and store.s_city in ('Pleasant Hill','Bethel') + group by store_sales.ss_ticket_number + ,store_sales.ss_customer_sk + ,store_sales.ss_addr_sk,customer_address.ca_city) dn + cross join {{customer}} as customer + cross join {{customer_address}} current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100; + +-- end query 1 in stream 0 using template query68.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q69.sql b/ydb/library/benchmarks/queries/tpcds/yql/q69.sql new file mode 100644 index 000000000000..e943fe93e26a --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q69.sql @@ -0,0 +1,60 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +$bla1 = (select ss_customer_sk customer_sk + from {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + where ss_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2); + +$bla2 = ((select ws_bill_customer_sk customer_sk + from {{web_sales}} as web_sales + cross join {{date_dim}} as date_dim + where + ws_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2) + union all + (select cs_ship_customer_sk customer_sk + from {{catalog_sales}} as catalog_sales + cross join {{date_dim}} as date_dim + where + cs_sold_date_sk = d_date_sk and + d_year = 2003 and + d_moy between 2 and 2+2) + ); + +-- start query 1 in stream 0 using template query69.tpl and seed 797269820 +select + customer_demographics.cd_gender, + customer_demographics.cd_marital_status, + customer_demographics.cd_education_status, + count(*) cnt1, + customer_demographics.cd_purchase_estimate, + count(*) cnt2, + customer_demographics.cd_credit_rating, + count(*) cnt3 + from + {{customer}} c + cross join {{customer_address}} ca + cross join {{customer_demographics}} as customer_demographics + left semi join $bla1 bla1 on c.c_customer_sk = bla1.customer_sk + left only join $bla2 bla2 on c.c_customer_sk = bla2.customer_sk + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('MO','MN','AZ') and + cd_demo_sk = c.c_current_cdemo_sk + group by customer_demographics.cd_gender, + customer_demographics.cd_marital_status, + customer_demographics.cd_education_status, + customer_demographics.cd_purchase_estimate, + customer_demographics.cd_credit_rating + order by customer_demographics.cd_gender, + customer_demographics.cd_marital_status, + customer_demographics.cd_education_status, + customer_demographics.cd_purchase_estimate, + customer_demographics.cd_credit_rating + limit 100; + +-- end query 1 in stream 0 using template query69.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q70.sql b/ydb/library/benchmarks/queries/tpcds/yql/q70.sql new file mode 100644 index 000000000000..cc88e393635a --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q70.sql @@ -0,0 +1,43 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query70.tpl and seed 1819994127 +select + sum(ss_net_profit) as total_sum + ,store.s_state + ,store.s_county + ,grouping(store.s_state)+grouping(store.s_county) as lochierarchy + ,rank() over ( + partition by grouping(store.s_state)+grouping(store.s_county), + case when grouping(store.s_county) = 0 then s_state else null end + order by sum(ss_net_profit) desc) as rank_within_parent + from + {{store_sales}} as store_sales + cross join {{date_dim}} d1 + cross join {{store}} as store + where + d1.d_month_seq between 1218 and 1218+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select store.s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from {{store_sales}} as store_sales + cross join {{store}} as store + cross join {{date_dim}} as date_dim + where d_month_seq between 1218 and 1218+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by store.s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(store.s_state,store.s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state else null end + ,rank_within_parent + limit 100; + +-- end query 1 in stream 0 using template query70.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q71.sql b/ydb/library/benchmarks/queries/tpcds/yql/q71.sql new file mode 100644 index 000000000000..b1dc96e6815c --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q71.sql @@ -0,0 +1,46 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query71.tpl and seed 2031708268 +select item.i_brand_id brand_id, item.i_brand brand,time_dim.t_hour,time_dim.t_minute, + sum(ext_price) ext_price + from {{item}} as item cross join (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from {{web_sales}} as web_sales + cross join {{date_dim}} as date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=2000 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from {{catalog_sales}} as catalog_sales + cross join {{date_dim}} as date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=2000 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=2000 + ) tmp cross join {{time_dim}} as time_dim + where + sold_item_sk = item.i_item_sk + and i_manager_id=1 + and time_sk = time_dim.t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by item.i_brand, item.i_brand_id,time_dim.t_hour,time_dim.t_minute + order by ext_price desc, brand_id + ; + +-- end query 1 in stream 0 using template query71.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q72.sql b/ydb/library/benchmarks/queries/tpcds/yql/q72.sql new file mode 100644 index 000000000000..bea4e9b92c11 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q72.sql @@ -0,0 +1,32 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query72.tpl and seed 2031708268 +select item.i_item_desc + ,warehouse.w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from {{catalog_sales}} as catalog_sales +join {{inventory}} as inventory on (catalog_sales.cs_item_sk = inventory.inv_item_sk) +join {{warehouse}} as warehouse on (warehouse.w_warehouse_sk=inventory.inv_warehouse_sk) +join {{item}} as item on (item.i_item_sk = catalog_sales.cs_item_sk) +join {{customer_demographics}} as customer_demographics on (catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk) +join {{household_demographics}} as household_demographics on (catalog_sales.cs_bill_hdemo_sk = household_demographics.hd_demo_sk) +join {{date_dim}} d1 on (catalog_sales.cs_sold_date_sk = d1.d_date_sk) +join {{date_dim}} d2 on (inventory.inv_date_sk = d2.d_date_sk) +join {{date_dim}} d3 on (catalog_sales.cs_ship_date_sk = d3.d_date_sk) +left join {{promotion}} as promotion on (catalog_sales.cs_promo_sk=promotion.p_promo_sk) +left join {{catalog_returns}} as catalog_returns on (catalog_returns.cr_item_sk = catalog_sales.cs_item_sk and catalog_returns.cr_order_number = catalog_sales.cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and cast(d3.d_date as date) > cast(d1.d_date as date) + DateTime::IntervalFromDays(5) + and hd_buy_potential = '1001-5000' + and d1.d_year = 2000 + and cd_marital_status = 'D' +group by item.i_item_desc,warehouse.w_warehouse_name,d1.d_week_seq +order by total_cnt desc, item.i_item_desc, warehouse.w_warehouse_name, d1.d_week_seq +limit 100; + +-- end query 1 in stream 0 using template query72.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q73.sql b/ydb/library/benchmarks/queries/tpcds/yql/q73.sql new file mode 100644 index 000000000000..b7ec1fc14b15 --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q73.sql @@ -0,0 +1,34 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +-- start query 1 in stream 0 using template query73.tpl and seed 1971067816 +select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select store_sales.ss_ticket_number ss_ticket_number + ,store_sales.ss_customer_sk ss_customer_sk + ,count(*) cnt + from {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + cross join {{store}} as store + cross join {{household_demographics}} as household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '>10000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Lea County','Furnas County','Pennington County','Bronx County') + group by store_sales.ss_ticket_number,store_sales.ss_customer_sk) dj cross join {{customer}} as customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc; + +-- end query 1 in stream 0 using template query73.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q74.sql b/ydb/library/benchmarks/queries/tpcds/yql/q74.sql new file mode 100644 index 000000000000..d44fb536299a --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q74.sql @@ -0,0 +1,65 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +$year_total = ( + select customer.c_customer_id customer_id + ,customer.c_first_name customer_first_name + ,customer.c_last_name customer_last_name + ,date_dim.d_year as year + ,sum(ss_net_paid) year_total + ,'s' sale_type + from {{customer}} as customer + cross join {{store_sales}} as store_sales + cross join {{date_dim}} as date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by customer.c_customer_id + ,customer.c_first_name + ,customer.c_last_name + ,date_dim.d_year + union all + select customer.c_customer_id customer_id + ,customer.c_first_name customer_first_name + ,customer.c_last_name customer_last_name + ,date_dim.d_year as year + ,sum(ws_net_paid) year_total + ,'w' sale_type + from {{customer}} as customer + cross join {{web_sales}} as web_sales + cross join {{date_dim}} as date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1998,1998+1) + group by customer.c_customer_id + ,customer.c_first_name + ,customer.c_last_name + ,date_dim.d_year + ); +-- start query 1 in stream 0 using template query74.tpl and seed 1556717815 + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from $year_total t_s_firstyear + cross join $year_total t_s_secyear + cross join $year_total t_w_firstyear + cross join $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.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+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 else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by t_s_secyear.customer_last_name,t_s_secyear.customer_id,t_s_secyear.customer_first_name +limit 100; + +-- end query 1 in stream 0 using template query74.tpl + diff --git a/ydb/library/benchmarks/queries/tpcds/yql/q75.sql b/ydb/library/benchmarks/queries/tpcds/yql/q75.sql new file mode 100644 index 000000000000..22bf4700138d --- /dev/null +++ b/ydb/library/benchmarks/queries/tpcds/yql/q75.sql @@ -0,0 +1,78 @@ +{% include 'header.sql.jinja' %} + +-- NB: Subquerys +$sales_detail = (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM {{catalog_sales}} as catalog_sales + JOIN {{item}} as item ON item.i_item_sk=catalog_sales.cs_item_sk + JOIN {{date_dim}} as date_dim ON date_dim.d_date_sk=catalog_sales.cs_sold_date_sk + LEFT JOIN {{catalog_returns}} as catalog_returns ON (catalog_sales.cs_order_number=catalog_returns.cr_order_number + AND catalog_sales.cs_item_sk=catalog_returns.cr_item_sk) + WHERE i_category='Sports' + UNION all + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM {{store_sales}} as store_sales + JOIN {{item}} as item ON item.i_item_sk=store_sales.ss_item_sk + JOIN {{date_dim}} as date_dim ON date_dim.d_date_sk=store_sales.ss_sold_date_sk + LEFT JOIN {{store_returns}} as store_returns ON (store_sales.ss_ticket_number=store_returns.sr_ticket_number + AND store_sales.ss_item_sk=store_returns.sr_item_sk) + WHERE i_category='Sports' + UNION all + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM {{web_sales}} as web_sales + JOIN {{item}} as item ON item.i_item_sk=web_sales.ws_item_sk + JOIN {{date_dim}} as date_dim ON date_dim.d_date_sk=web_sales.ws_sold_date_sk + LEFT JOIN {{web_returns}} as web_returns ON (web_sales.ws_order_number=web_returns.wr_order_number + AND web_sales.ws_item_sk=web_returns.wr_item_sk) + WHERE i_category='Sports'); + +$all_sales = ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (select DISTINCT * from $sales_detail) sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id); +-- start query 1 in stream 0 using template query75.tpl and seed 1819994127 + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM $all_sales curr_yr cross join $all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 + AND cast((CAST(curr_yr.sales_cnt AS decimal(17, 2))/CAST(prev_yr.sales_cnt AS decimal(17, 2))) AS double)<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100; + +-- end query 1 in stream 0 using template query75.tpl