Skip to content

Commit

Permalink
Add modifications for DATE type
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrahn committed Dec 20, 2019
1 parent 475d754 commit e63db94
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 111 deletions.
4 changes: 2 additions & 2 deletions queries/query12.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ where
ws_item_sk = i_item_sk
and i_category in ('Jewelry', 'Sports', 'Books')
and ws_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between cast('2001-01-12' as timestamp)
and (cast('2001-01-12' as timestamp) + interval 30 days)
and d_date between cast('2001-01-12' as date)
and (cast('2001-01-12' as date) + interval 30 days)
group by
i_item_id
,i_item_desc
Expand Down
4 changes: 2 additions & 2 deletions queries/query16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ from
,customer_address
,call_center
where
cast(d_date as timestamp) between cast('1999-04-01' as timestamp) and
(cast('1999-04-01' as timestamp) + interval 60 days)
d_date between cast('1999-4-01' as date) and
(cast('1999-4-01' as date) + interval 60 days)
and cs1.cs_ship_date_sk = d_date_sk
and cs1.cs_ship_addr_sk = ca_address_sk
and ca_state = 'IA'
Expand Down
4 changes: 2 additions & 2 deletions queries/query20.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ select i_item_id
where cs_item_sk = i_item_sk
and i_category in ('Jewelry', 'Sports', 'Books')
and cs_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between cast('2001-01-12' as timestamp)
and (cast('2001-01-12' as timestamp) + interval 30 days)
and d_date between cast('2001-01-12' as date)
and (cast('2001-01-12' as date) + interval 30 days)
group by i_item_id
,i_item_desc
,i_category
Expand Down
8 changes: 4 additions & 4 deletions queries/query21.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
select *
from(select w_warehouse_name
,i_item_id
,sum(case when (cast(d_date as timestamp) < cast ('1998-04-08' as timestamp))
,sum(case when d_date < cast ('1998-04-08' as date)
then inv_quantity_on_hand
else 0 end) as inv_before
,sum(case when (cast(d_date as timestamp) >= cast ('1998-04-08' as timestamp))
,sum(case when d_date >= cast ('1998-04-08' as date)
then inv_quantity_on_hand
else 0 end) as inv_after
from inventory
Expand All @@ -16,8 +16,8 @@ select *
and i_item_sk = inv_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and cast(d_date as timestamp) between (cast ('1998-04-08' as timestamp) - interval 30 days)
and (cast ('1998-04-08' as timestamp) + interval 30 days)
and d_date between (cast ('1998-04-08' as date) - interval 30 days)
and (cast ('1998-04-08' as date) + interval 30 days)
group by w_warehouse_name, i_item_id) x
where (case when inv_before > 0
then inv_after / inv_before
Expand Down
8 changes: 4 additions & 4 deletions queries/query32.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from
where
i_manufact_id = 269
and i_item_sk = cs_item_sk
and cast(d_date as timestamp) between cast('1998-03-18' as timestamp) and
(cast('1998-03-18' as timestamp) + interval 90 days)
and d_date between cast('1998-03-18' as date) and
(cast('1998-03-18' as date) + interval 90 days)
and d_date_sk = cs_sold_date_sk
and cs_ext_discount_amt
> (
Expand All @@ -19,8 +19,8 @@ and cs_ext_discount_amt
,date_dim
where
cs_item_sk = i_item_sk
and cast(d_date as timestamp) between cast('1998-03-18' as timestamp) and
(cast('1998-03-18' as timestamp) + interval 90 days)
and d_date between cast('1998-03-18' as date) and
(cast('1998-03-18' as date) + interval 90 days)
and d_date_sk = cs_sold_date_sk
)
limit 100;
Expand Down
2 changes: 1 addition & 1 deletion queries/query37.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ select i_item_id
where i_current_price between 22 and 22 + 30
and inv_item_sk = i_item_sk
and d_date_sk=inv_date_sk
and cast(d_date as timestamp) between cast('2001-06-02' as timestamp) and (cast('2001-06-02' as timestamp) + interval 60 days)
and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) + interval 60 days)
and i_manufact_id in (678,964,918,849)
and inv_quantity_on_hand between 100 and 500
and cs_item_sk = i_item_sk
Expand Down
8 changes: 4 additions & 4 deletions queries/query40.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
select
w_state
,i_item_id
,sum(case when (cast(d_date as timestamp) < cast ('1998-04-08' as timestamp))
,sum(case when d_date < cast ('1998-04-08' as date)
then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
,sum(case when (cast(d_date as timestamp) >= cast ('1998-04-08' as timestamp))
,sum(case when d_date >= cast ('1998-04-08' as date)
then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
from
catalog_sales left outer join catalog_returns on
Expand All @@ -18,8 +18,8 @@ select
and i_item_sk = cs_item_sk
and cs_warehouse_sk = w_warehouse_sk
and cs_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between (cast ('1998-04-08' as timestamp) - interval 30 days)
and (cast ('1998-04-08' as timestamp) + interval 30 days)
and d_date between (cast ('1998-04-08' as date) - interval 30 days)
and (cast ('1998-04-08' as date) + interval 30 days)
group by
w_state,i_item_id
order by w_state,i_item_id
Expand Down
12 changes: 6 additions & 6 deletions queries/query5a.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ with ssr as
date_dim,
store
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 14 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 14 days)
and store_sk = s_store_sk
group by s_store_id)
,
Expand Down Expand Up @@ -56,8 +56,8 @@ with ssr as
date_dim,
catalog_page
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 14 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 14 days)
and page_sk = cp_catalog_page_sk
group by cp_catalog_page_id)
,
Expand Down Expand Up @@ -89,8 +89,8 @@ with ssr as
date_dim,
web_site
where date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 14 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 14 days)
and wsr_web_site_sk = web_site_sk
group by web_site_id)
,
Expand Down
2 changes: 1 addition & 1 deletion queries/query72.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ left outer join promotion on (cs_promo_sk=p_promo_sk)
left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = 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 timestamp) > cast(d1.d_date as timestamp) + interval 5 days
and d3.d_date > d1.d_date + interval 5 days
and hd_buy_potential = '1001-5000'
and d1.d_year = 2001
and cd_marital_status = 'M'
Expand Down
24 changes: 12 additions & 12 deletions queries/query77a.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ with ss as
date_dim,
store
where ss_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
and ss_store_sk = s_store_sk
group by s_store_sk)
,
Expand All @@ -20,8 +20,8 @@ with ss as
date_dim,
store
where sr_returned_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
and sr_store_sk = s_store_sk
group by s_store_sk),
cs as
Expand All @@ -31,8 +31,8 @@ with ss as
from catalog_sales,
date_dim
where cs_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
group by cs_call_center_sk
),
cr as
Expand All @@ -42,8 +42,8 @@ with ss as
from catalog_returns,
date_dim
where cr_returned_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
group by cr_call_center_sk),
ws as
( select wp_web_page_sk,
Expand All @@ -53,8 +53,8 @@ with ss as
date_dim,
web_page
where ws_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
and ws_web_page_sk = wp_web_page_sk
group by wp_web_page_sk),
wr as
Expand All @@ -65,8 +65,8 @@ with ss as
date_dim,
web_page
where wr_returned_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days )
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days )
and wr_web_page_sk = wp_web_page_sk
group by wp_web_page_sk)
,
Expand Down
12 changes: 6 additions & 6 deletions queries/query80a.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ with ssr as
item,
promotion
where ss_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days)
and ss_store_sk = s_store_sk
and ss_item_sk = i_item_sk
and i_current_price > 50
Expand All @@ -32,8 +32,8 @@ with ssr as
item,
promotion
where cs_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days)
and cs_catalog_page_sk = cp_catalog_page_sk
and cs_item_sk = i_item_sk
and i_current_price > 50
Expand All @@ -53,8 +53,8 @@ group by cp_catalog_page_id)
item,
promotion
where ws_sold_date_sk = d_date_sk
and d_date between cast('1998-08-04' as timestamp)
and (cast('1998-08-04' as timestamp) + interval 30 days)
and d_date between cast('1998-08-04' as date)
and (cast('1998-08-04' as date) + interval 30 days)
and ws_web_site_sk = web_site_sk
and ws_item_sk = i_item_sk
and i_current_price > 50
Expand Down
2 changes: 1 addition & 1 deletion queries/query82.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ select i_item_id
where i_current_price between 30 and 30+30
and inv_item_sk = i_item_sk
and d_date_sk=inv_date_sk
and cast(d_date as timestamp) between cast('2002-05-30' as timestamp) and (cast('2002-05-30' as timestamp) + interval 60 days)
and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) + interval 60 days)
and i_manufact_id in (437,129,727,663)
and inv_quantity_on_hand between 100 and 500
and ss_item_sk = i_item_sk
Expand Down
8 changes: 4 additions & 4 deletions queries/query92.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ from
where
i_manufact_id = 269
and i_item_sk = ws_item_sk
and cast(d_date as timestamp) between cast('1998-03-18' as timestamp) and
(cast('1998-03-18' as timestamp) + interval 90 days)
and d_date between cast('1998-03-18' as date) and
(cast('1998-03-18' as date) + interval 90 days)
and d_date_sk = ws_sold_date_sk
and ws_ext_discount_amt
> (
Expand All @@ -20,8 +20,8 @@ and ws_ext_discount_amt
,date_dim
WHERE
ws_item_sk = i_item_sk
and cast(d_date as timestamp) between cast('1998-03-18' as timestamp) and
(cast('1998-03-18' as timestamp) + interval 90 days)
and d_date between cast('1998-03-18' as date) and
(cast('1998-03-18' as date) + interval 90 days)
and d_date_sk = ws_sold_date_sk
)
order by sum(ws_ext_discount_amt)
Expand Down
4 changes: 2 additions & 2 deletions queries/query94.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ from
,customer_address
,web_site
where
cast(d_date as timestamp) between cast('1999-05-01' as timestamp) and
(cast('1999-05-01' as timestamp) + interval 60 days)
d_date between cast('1999-5-01' as date) and
(cast('1999-5-01' as date) + interval 60 days)
and ws1.ws_ship_date_sk = d_date_sk
and ws1.ws_ship_addr_sk = ca_address_sk
and ca_state = 'TX'
Expand Down
4 changes: 2 additions & 2 deletions queries/query95.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ from
,customer_address
,web_site
where
cast(d_date as timestamp) between cast('1999-05-01' as timestamp) and
(cast('1999-05-01' as timestamp) + interval 60 days)
d_date between cast('1999-05-01' as date) and
(cast('1999-05-01' as date) + interval 60 days)
and ws1.ws_ship_date_sk = d_date_sk
and ws1.ws_ship_addr_sk = ca_address_sk
and ca_state = 'TX'
Expand Down
4 changes: 2 additions & 2 deletions queries/query98.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ where
ss_item_sk = i_item_sk
and i_category in ('Jewelry', 'Sports', 'Books')
and ss_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between cast('2001-01-12' as timestamp)
and (cast('2001-01-12' as timestamp) + interval 30 days)
and d_date between cast('2001-01-12' as date)
and (cast('2001-01-12' as date) + interval 30 days)
group by
i_item_id
,i_item_desc
Expand Down
2 changes: 1 addition & 1 deletion query-templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following query variants are used:
The following MQM are used:

- Use of vendor-specific syntax of date expressions and date casting. (MQM f.1, f.8)
- q5a
- query5a
- query12
- query16
- query20
Expand Down
4 changes: 2 additions & 2 deletions query-templates/query12.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ where
ws_item_sk = i_item_sk
and i_category in ('[CATEGORY.1]', '[CATEGORY.2]', '[CATEGORY.3]')
and ws_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between cast('[SDATE]' as timestamp)
and (cast('[SDATE]' as timestamp) + interval 30 days)
and d_date between cast('[SDATE]' as date)
and (cast('[SDATE]' as date) + interval 30 days)
group by
i_item_id
,i_item_desc
Expand Down
4 changes: 2 additions & 2 deletions query-templates/query16.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ from
,customer_address
,call_center
where
cast(d_date as timestamp) between cast('[YEAR]-0[MONTH]-01' as timestamp) and
(cast('[YEAR]-0[MONTH]-01' as timestamp) + interval 60 days)
d_date between cast('[YEAR]-[MONTH]-01' as date) and
(cast('[YEAR]-[MONTH]-01' as date) + interval 60 days)
and cs1.cs_ship_date_sk = d_date_sk
and cs1.cs_ship_addr_sk = ca_address_sk
and ca_state = '[STATE]'
Expand Down
4 changes: 2 additions & 2 deletions query-templates/query20.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
where cs_item_sk = i_item_sk
and i_category in ('[CATEGORY.1]', '[CATEGORY.2]', '[CATEGORY.3]')
and cs_sold_date_sk = d_date_sk
and cast(d_date as timestamp) between cast('[SDATE]' as timestamp)
and (cast('[SDATE]' as timestamp) + interval 30 days)
and d_date between cast('[SDATE]' as date)
and (cast('[SDATE]' as date) + interval 30 days)
group by i_item_id
,i_item_desc
,i_category
Expand Down
8 changes: 4 additions & 4 deletions query-templates/query21.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
[_LIMITA] select [_LIMITB] *
from(select w_warehouse_name
,i_item_id
,sum(case when (cast(d_date as timestamp) < cast ('[SALES_DATE]' as timestamp))
,sum(case when d_date < cast ('[SALES_DATE]' as date)
then inv_quantity_on_hand
else 0 end) as inv_before
,sum(case when (cast(d_date as timestamp) >= cast ('[SALES_DATE]' as timestamp))
,sum(case when d_date >= cast ('[SALES_DATE]' as date)
then inv_quantity_on_hand
else 0 end) as inv_after
from inventory
Expand All @@ -53,8 +53,8 @@
and i_item_sk = inv_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and cast(d_date as timestamp) between (cast ('[SALES_DATE]' as timestamp) - interval 30 days)
and (cast ('[SALES_DATE]' as timestamp) + interval 30 days)
and d_date between (cast ('[SALES_DATE]' as date) - interval 30 days)
and (cast ('[SALES_DATE]' as date) + interval 30 days)
group by w_warehouse_name, i_item_id) x
where (case when inv_before > 0
then inv_after / inv_before
Expand Down
Loading

0 comments on commit e63db94

Please sign in to comment.