forked from llooker/snowflake-usage-block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
warehouse_metering_history.view.lkml
98 lines (85 loc) · 1.89 KB
/
warehouse_metering_history.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
view: warehouse_metering_history {
sql_table_name: SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY ;;
dimension: credits_used {
type: number
sql: ${TABLE}.CREDITS_USED ;;
alias: [credits]
}
dimension_group: start {
type: time
timeframes: [
raw,
time,
date,
day_of_month,
day_of_week,
day_of_year,
week,
week_of_year,
month,
month_num,
quarter,
year
]
sql: ${TABLE}.START_TIME ;;
alias: [read_hour]
}
dimension_group: end {
type: time
timeframes: [
raw,
time,
date,
day_of_month,
day_of_week,
day_of_year,
week,
week_of_year,
month,
month_num,
quarter,
year
]
sql: ${TABLE}.END_TIME ;;
}
# dimension: warehouse_id {
# type: string
# sql: ${TABLE}.WAREHOUSE_ID ;;
# }
dimension: warehouse_name {
type: string
sql: ${TABLE}.WAREHOUSE_NAME ;;
}
dimension: is_prior_month_mtd {
type: yesno
sql: EXTRACT(month, ${start_raw}) = EXTRACT(month, current_timestamp()) - 1
and ${start_raw} <= dateadd(month, -1, current_timestamp()) ;;
}
measure: count {
type: count
drill_fields: [warehouse_name,count]
}
measure: average_credits_used {
type: average
sql: ${credits_used} ;;
drill_fields: [start_date, average_credits_used]
}
measure: total_credits_used {
type: sum
sql: ${credits_used} ;;
value_format_name: usd_0
drill_fields: [start_date, total_credits_used]
}
measure: current_mtd_credits_used {
type: sum
sql: ${credits_used} ;;
filters: {field: start_date value: "this month"}
value_format: "$0.000,\" K\""
drill_fields: [warehouse_name,total_credits_used]
}
measure: prior_mtd_credits_used {
type: sum
sql: ${credits_used} ;;
filters: {field: is_prior_month_mtd value: "yes"}
}
}