-
Notifications
You must be signed in to change notification settings - Fork 15
/
calendar.view.lkml
70 lines (69 loc) · 1.74 KB
/
calendar.view.lkml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
view: calendar {
derived_table: {
sql_trigger_value: select current_date ;;
indexes: ["cal_date"]
distribution_style: all
sql: SELECT
DATEADD('days',
(p0.n
+ p1.n*2
+ p2.n * POWER(2,2)
+ p3.n * POWER(2,3)
+ p4.n * POWER(2,4)
+ p5.n * POWER(2,5)
+ p6.n * POWER(2,6)
+ p7.n * POWER(2,7)
+ p8.n * POWER(2,8)
+ p9.n * POWER(2,9)
+ p10.n * POWER(2,10)
)::int
, '2012-11-01'::date
)
as cal_date
FROM
(SELECT 0 as n UNION SELECT 1) p0,
(SELECT 0 as n UNION SELECT 1) p1,
(SELECT 0 as n UNION SELECT 1) p2,
(SELECT 0 as n UNION SELECT 1) p3,
(SELECT 0 as n UNION SELECT 1) p4,
(SELECT 0 as n UNION SELECT 1) p5,
(SELECT 0 as n UNION SELECT 1) p6,
(SELECT 0 as n UNION SELECT 1) p7,
(SELECT 0 as n UNION SELECT 1) p8,
(SELECT 0 as n UNION SELECT 1) p9,
(SELECT 0 as n UNION SELECT 1) p10
WHERE
DATEADD('days',
(p0.n
+ p1.n*2
+ p2.n * POWER(2,2)
+ p3.n * POWER(2,3)
+ p4.n * POWER(2,4)
+ p5.n * POWER(2,5)
+ p6.n * POWER(2,6)
+ p7.n * POWER(2,7)
+ p8.n * POWER(2,8)
+ p9.n * POWER(2,9)
+ p10.n * POWER(2,10)
)::int
, '2012-11-01'::date
) <= current_date
;;
}
dimension_group: cal_date {
type: time
timeframes: [
year,
month,
date,
day_of_week,
month_num,
day_of_week_index,
quarter,
quarter_of_year,
week,
week_of_year
]
sql: ${TABLE}.cal_date ;;
}
}