-
Notifications
You must be signed in to change notification settings - Fork 60
/
storage_usage.view.lkml
96 lines (82 loc) · 2.01 KB
/
storage_usage.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
view: storage_usage {
sql_table_name:
{% if database_name._in_query or database_id._in_query %}
SNOWFLAKE.ACCOUNT_USAGE.DATABASE_STORAGE_USAGE_HISTORY
{% else %}
SNOWFLAKE.ACCOUNT_USAGE.STORAGE_USAGE
{% endif %};;
dimension: database_id {
type: number
sql: ${TABLE}.DATABASE_ID ;;
}
dimension_group: deleted {
#if this is exposed - will need to include it table selection logic
type: time
hidden: yes
sql: ${TABLE}.DELETED ;;
}
dimension: database_name {
type: string
sql: ${TABLE}.DATABASE_NAME ;;
}
dimension_group: usage {
type: time
datatype: date
timeframes: [date,week,week_of_year,day_of_week,day_of_month,month_num,month,quarter,year]
convert_tz: no
sql: ${TABLE}.USAGE_DATE ;;
alias: [read]
}
dimension: storage_bytes {
type: number
sql: {% if database_name._in_query or database_id._in_query %}
${TABLE}.AVERAGE_DATABASE_BYTES
{% else %}
${TABLE}.STORAGE_BYTES
{% endif %}
;;
}
dimension: failsafe_bytes {
type: number
sql: {% if database_name._in_query or database_id._in_query %}
${TABLE}.AVERAGE_FAILSAFE_BYTES
{% else %}
${TABLE}.FAILSAFE_BYTES
{% endif %};;
}
dimension: storage_tb {
type: number
sql: ${storage_bytes} / power(1024,4) ;;
}
measure: average_storage_tb {
type: average
sql: ${storage_tb} ;;
}
dimension: failsafe_tb {
type: number
sql: ${failsafe_bytes} / power(1024,4) ;;
}
dimension: total_tb {
sql: ${storage_tb} + ${failsafe_tb};;
}
measure: count {
type: count
drill_fields: []
}
measure: billable_tb {
type: average
sql: ${total_tb};;
}
measure: curr_mtd_billable_tb {
type: average
sql: ${total_tb};;
filters: {field: usage_date value: "this month"}
value_format_name: decimal_4
}
measure: prior_mtd_billable_tb {
type: average
sql: ${storage_tb} + ${failsafe_tb};;
filters: {field: usage_date value: "last month"}
value_format_name: decimal_4
}
}