forked from dbt-labs/dbt-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dateadd.sql
More file actions
33 lines (31 loc) · 975 Bytes
/
test_dateadd.sql
File metadata and controls
33 lines (31 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
with data as (select * from {{ ref("data_dateadd") }})
select
case
when datepart = 'hour'
then
cast(
{{ dbt_utils.dateadd("hour", "interval_length", "from_time") }}
as {{ dbt_utils.type_timestamp() }}
)
when datepart = 'day'
then
cast(
{{ dbt_utils.dateadd("day", "interval_length", "from_time") }}
as {{ dbt_utils.type_timestamp() }}
)
when datepart = 'month'
then
cast(
{{ dbt_utils.dateadd("month", "interval_length", "from_time") }}
as {{ dbt_utils.type_timestamp() }}
)
when datepart = 'year'
then
cast(
{{ dbt_utils.dateadd("year", "interval_length", "from_time") }}
as {{ dbt_utils.type_timestamp() }}
)
else null
end as actual,
result as expected
from data