Skip to content

Commit

Permalink
Use the same constants in both tpc-ds version (yql and pg) (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius authored Jan 29, 2024
1 parent 1b1d8f3 commit d0648a1
Show file tree
Hide file tree
Showing 90 changed files with 783 additions and 783 deletions.
2 changes: 1 addition & 1 deletion ydb/library/benchmarks/queries/tpcds/pg/q01.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2::numeric
from customer_total_return ctr2
where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
and s_store_sk = ctr1.ctr_store_sk
and s_state = 'TN'
and s_state = 'NM'
and ctr1.ctr_customer_sk = c_customer_sk
order by c_customer_id
limit 100;
Expand Down
12 changes: 6 additions & 6 deletions ydb/library/benchmarks/queries/tpcds/pg/q02.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ with wscs as
,sales_price
from (select ws_sold_date_sk sold_date_sk
,ws_ext_sales_price sales_price
from {{web_sales}}
from {{web_sales}}
union all
select cs_sold_date_sk sold_date_sk
,cs_ext_sales_price sales_price
from {{catalog_sales}}) a),
wswscs as
wswscs as
(select d_week_seq,
sum(case when (d_day_name='Sunday') then sales_price else null::numeric end) sun_sales,
sum(case when (d_day_name='Monday') then sales_price else null::numeric end) mon_sales,
Expand Down Expand Up @@ -40,9 +40,9 @@ with wscs as
,thu_sales thu_sales1
,fri_sales fri_sales1
,sat_sales sat_sales1
from wswscs,{{date_dim}}
from wswscs,{{date_dim}}
where date_dim.d_week_seq = wswscs.d_week_seq and
d_year = 2001) y,
d_year = 1998) y,
(select wswscs.d_week_seq d_week_seq2
,sun_sales sun_sales2
,mon_sales mon_sales2
Expand All @@ -52,9 +52,9 @@ with wscs as
,fri_sales fri_sales2
,sat_sales sat_sales2
from wswscs
,{{date_dim}}
,{{date_dim}}
where date_dim.d_week_seq = wswscs.d_week_seq and
d_year = 2001+1) z
d_year = 1998+1) z
where d_week_seq1=d_week_seq2-53
order by d_week_seq1;

Expand Down
10 changes: 5 additions & 5 deletions ydb/library/benchmarks/queries/tpcds/pg/q03.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{% include 'header.sql.jinja' %}

select dt.d_year
,item.i_brand_id brand_id
select dt.d_year
,item.i_brand_id brand_id
,item.i_brand brand
,sum(ss_ext_sales_price) sum_agg
from {{date_dim}} dt
from {{date_dim}} dt
,{{store_sales}}
,{{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_manufact_id = 436
and dt.d_moy=12
and item.i_manufact_id = 816
and dt.d_moy=11
group by dt.d_year
,item.i_brand
,item.i_brand_id
Expand Down
14 changes: 7 additions & 7 deletions ydb/library/benchmarks/queries/tpcds/pg/q04.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ union all
,c_email_address
,d_year
)
select
select
t_s_secyear.customer_id
,t_s_secyear.customer_first_name
,t_s_secyear.customer_last_name
Expand All @@ -95,12 +95,12 @@ union all
and t_s_secyear.sale_type = 's'
and t_c_secyear.sale_type = 'c'
and t_w_secyear.sale_type = 'w'
and t_s_firstyear.dyear = 2001
and t_s_secyear.dyear = 2001+1
and t_c_firstyear.dyear = 2001
and t_c_secyear.dyear = 2001+1
and t_w_firstyear.dyear = 2001
and t_w_secyear.dyear = 2001+1
and t_s_firstyear.dyear = 1999
and t_s_secyear.dyear = 1999+1
and t_c_firstyear.dyear = 1999
and t_c_secyear.dyear = 1999+1
and t_w_firstyear.dyear = 1999
and t_w_secyear.dyear = 1999+1
and t_s_firstyear.year_total > 0::numeric
and t_c_firstyear.year_total > 0::numeric
and t_w_firstyear.year_total > 0::numeric
Expand Down
14 changes: 7 additions & 7 deletions ydb/library/benchmarks/queries/tpcds/pg/q05.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ with ssr as
{{date_dim}},
{{store}}
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval '14' day)::date
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + interval '14' day)::date
and store_sk = s_store_sk
group by s_store_id)
,
Expand Down Expand Up @@ -57,8 +57,8 @@ with ssr as
{{date_dim}},
{{catalog_page}}
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval '14' day)::date
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + interval '14' day)::date
and page_sk = cp_catalog_page_sk
group by cp_catalog_page_id)
,
Expand Down Expand Up @@ -90,16 +90,16 @@ with ssr as
{{date_dim}},
{{web_site}}
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval '14' day)::date
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + interval '14' day)::date
and wsr_web_site_sk = web_site_sk
group by web_site_id)
select channel
, id
, sum(sales) as sales
, sum(returns) as returns
, sum(profit) as profit
from
from
(select 'store channel' as channel
, 'store' || s_store_id as id
, sales
Expand Down
14 changes: 7 additions & 7 deletions ydb/library/benchmarks/queries/tpcds/pg/q06.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ select a.ca_state state, count(*) cnt
and c.c_customer_sk = s.ss_customer_sk
and s.ss_sold_date_sk = d.d_date_sk
and s.ss_item_sk = i.i_item_sk
and d.d_month_seq =
and d.d_month_seq =
(select distinct (d_month_seq)
from {{date_dim}}
where d_year = 2000
and d_moy = 2 )
and i.i_current_price > 1.2::numeric *
(select avg(j.i_current_price)
from {{item}} j
where d_year = 2002
and d_moy = 3 )
and i.i_current_price > 1.2::numeric *
(select avg(j.i_current_price)
from {{item}} j
where j.i_category = i.i_category)
group by a.ca_state
having count(*) >= 10
order by cnt, a.ca_state
order by cnt, a.ca_state
limit 100;

-- end query 1 in stream 0 using template ../query_templates/query6.tpl
10 changes: 5 additions & 5 deletions ydb/library/benchmarks/queries/tpcds/pg/q07.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{% include 'header.sql.jinja' %}

select i_item_id,
select i_item_id,
avg(ss_quantity) agg1,
avg(ss_list_price) agg2,
avg(ss_coupon_amt) agg3,
avg(ss_sales_price) agg4
avg(ss_sales_price) agg4
from {{store_sales}}, {{customer_demographics}}, {{date_dim}}, {{item}}, {{promotion}}
where ss_sold_date_sk = d_date_sk and
ss_item_sk = i_item_sk and
ss_cdemo_sk = cd_demo_sk and
ss_promo_sk = p_promo_sk and
cd_gender = 'F' and
cd_gender = 'F' and
cd_marital_status = 'W' and
cd_education_status = 'Primary' and
cd_education_status = 'College' and
(p_channel_email = 'N' or p_channel_event = 'N') and
d_year = 1998
d_year = 2001
group by i_item_id
order by i_item_id
limit 100;
Expand Down
162 changes: 81 additions & 81 deletions ydb/library/benchmarks/queries/tpcds/pg/q08.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,86 +10,86 @@ select s_store_name
SELECT substr(ca_zip,1,5) ca_zip
FROM {{customer_address}}
WHERE substr(ca_zip,1,5) IN (
'89436','30868','65085','22977','83927','77557',
'58429','40697','80614','10502','32779',
'91137','61265','98294','17921','18427',
'21203','59362','87291','84093','21505',
'17184','10866','67898','25797','28055',
'18377','80332','74535','21757','29742',
'90885','29898','17819','40811','25990',
'47513','89531','91068','10391','18846',
'99223','82637','41368','83658','86199',
'81625','26696','89338','88425','32200',
'81427','19053','77471','36610','99823',
'43276','41249','48584','83550','82276',
'18842','78890','14090','38123','40936',
'34425','19850','43286','80072','79188',
'54191','11395','50497','84861','90733',
'21068','57666','37119','25004','57835',
'70067','62878','95806','19303','18840',
'19124','29785','16737','16022','49613',
'89977','68310','60069','98360','48649',
'39050','41793','25002','27413','39736',
'47208','16515','94808','57648','15009',
'80015','42961','63982','21744','71853',
'81087','67468','34175','64008','20261',
'11201','51799','48043','45645','61163',
'48375','36447','57042','21218','41100',
'89951','22745','35851','83326','61125',
'78298','80752','49858','52940','96976',
'63792','11376','53582','18717','90226',
'50530','94203','99447','27670','96577',
'57856','56372','16165','23427','54561',
'28806','44439','22926','30123','61451',
'92397','56979','92309','70873','13355',
'21801','46346','37562','56458','28286',
'47306','99555','69399','26234','47546',
'49661','88601','35943','39936','25632',
'24611','44166','56648','30379','59785',
'11110','14329','93815','52226','71381',
'13842','25612','63294','14664','21077',
'82626','18799','60915','81020','56447',
'76619','11433','13414','42548','92713',
'70467','30884','47484','16072','38936',
'13036','88376','45539','35901','19506',
'65690','73957','71850','49231','14276',
'20005','18384','76615','11635','38177',
'55607','41369','95447','58581','58149',
'91946','33790','76232','75692','95464',
'22246','51061','56692','53121','77209',
'15482','10688','14868','45907','73520',
'72666','25734','17959','24677','66446',
'94627','53535','15560','41967','69297',
'11929','59403','33283','52232','57350',
'43933','40921','36635','10827','71286',
'19736','80619','25251','95042','15526',
'36496','55854','49124','81980','35375',
'49157','63512','28944','14946','36503',
'54010','18767','23969','43905','66979',
'33113','21286','58471','59080','13395',
'79144','70373','67031','38360','26705',
'50906','52406','26066','73146','15884',
'31897','30045','61068','45550','92454',
'13376','14354','19770','22928','97790',
'50723','46081','30202','14410','20223',
'88500','67298','13261','14172','81410',
'93578','83583','46047','94167','82564',
'21156','15799','86709','37931','74703',
'83103','23054','70470','72008','49247',
'91911','69998','20961','70070','63197',
'54853','88191','91830','49521','19454',
'81450','89091','62378','25683','61869',
'51744','36580','85778','36871','48121',
'28810','83712','45486','67393','26935',
'42393','20132','55349','86057','21309',
'80218','10094','11357','48819','39734',
'40758','30432','21204','29467','30214',
'61024','55307','74621','11622','68908',
'33032','52868','99194','99900','84936',
'69036','99149','45013','32895','59004',
'32322','14933','32936','33562','72550',
'27385','58049','58200','16808','21360',
'32961','18586','79307','15492')
'47602','16704','35863','28577','83910','36201',
'58412','48162','28055','41419','80332',
'38607','77817','24891','16226','18410',
'21231','59345','13918','51089','20317',
'17167','54585','67881','78366','47770',
'18360','51717','73108','14440','21800',
'89338','45859','65501','34948','25973',
'73219','25333','17291','10374','18829',
'60736','82620','41351','52094','19326',
'25214','54207','40936','21814','79077',
'25178','75742','77454','30621','89193',
'27369','41232','48567','83041','71948',
'37119','68341','14073','16891','62878',
'49130','19833','24286','27700','40979',
'50412','81504','94835','84844','71954',
'39503','57649','18434','24987','12350',
'86379','27413','44529','98569','16515',
'27287','24255','21094','16005','56436',
'91110','68293','56455','54558','10298',
'83647','32754','27052','51766','19444',
'13869','45645','94791','57631','20712',
'37788','41807','46507','21727','71836',
'81070','50632','88086','63991','20244',
'31655','51782','29818','63792','68605',
'94898','36430','57025','20601','82080',
'33869','22728','35834','29086','92645',
'98584','98072','11652','78093','57553',
'43830','71144','53565','18700','90209',
'71256','38353','54364','28571','96560',
'57839','56355','50679','45266','84680',
'34306','34972','48530','30106','15371',
'92380','84247','92292','68852','13338',
'34594','82602','70073','98069','85066',
'47289','11686','98862','26217','47529',
'63294','51793','35926','24227','14196',
'24594','32489','99060','49472','43432',
'49211','14312','88137','47369','56877',
'20534','81755','15794','12318','21060',
'73134','41255','63073','81003','73873',
'66057','51184','51195','45676','92696',
'70450','90669','98338','25264','38919',
'59226','58581','60298','17895','19489',
'52301','80846','95464','68770','51634',
'19988','18367','18421','11618','67975',
'25494','41352','95430','15734','62585',
'97173','33773','10425','75675','53535',
'17879','41967','12197','67998','79658',
'59130','72592','14851','43933','68101',
'50636','25717','71286','24660','58058',
'72991','95042','15543','33122','69280',
'11912','59386','27642','65177','17672',
'33467','64592','36335','54010','18767',
'63193','42361','49254','33113','33159',
'36479','59080','11855','81963','31016',
'49140','29392','41836','32958','53163',
'13844','73146','23952','65148','93498',
'14530','46131','58454','13376','13378',
'83986','12320','17193','59852','46081',
'98533','52389','13086','68843','31013',
'13261','60560','13443','45533','83583',
'11489','58218','19753','22911','25115',
'86709','27156','32669','13123','51933',
'39214','41331','66943','14155','69998',
'49101','70070','35076','14242','73021',
'59494','15782','29752','37914','74686',
'83086','34473','15751','81084','49230',
'91894','60624','17819','28810','63180',
'56224','39459','55233','75752','43639',
'55349','86057','62361','50788','31830',
'58062','18218','85761','60083','45484',
'21204','90229','70041','41162','35390',
'16364','39500','68908','26689','52868',
'81335','40146','11340','61527','61794',
'71997','30415','59004','29450','58117',
'69952','33562','83833','27385','61860',
'96435','48333','23065','32961','84919',
'61997','99132','22815','56600','68730',
'48017','95694','32919','88217','27116',
'28239','58032','18884','16791','21343',
'97462','18569','75660','15475')
intersect
select ca_zip
from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
Expand All @@ -100,7 +100,7 @@ select s_store_name
having count(*) > 10)A1)A2) V1
where ss_store_sk = s_store_sk
and ss_sold_date_sk = d_date_sk
and d_qoy = 1 and d_year = 2002
and d_qoy = 2 and d_year = 1998
and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
group by s_store_name
order by s_store_name
Expand Down
Loading

0 comments on commit d0648a1

Please sign in to comment.