-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus_cnapi.view.lkml
94 lines (82 loc) · 2.61 KB
/
status_cnapi.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
view: status_cnapi {
derived_table: {
sql: SELECT * FROM (
SELECT *, DENSE_RANK() OVER (ORDER BY z___min_rank) as z___pivot_row_rank, RANK() OVER (PARTITION BY z__pivot_col_rank ORDER BY z___min_rank) as z__pivot_col_ordering FROM (
SELECT *, MIN(z___rank) OVER (PARTITION BY "cnapi.date_date") as z___min_rank FROM (
SELECT *, RANK() OVER (ORDER BY "cnapi.date_date" DESC, z__pivot_col_rank) AS z___rank FROM (
SELECT *, DENSE_RANK() OVER (ORDER BY CASE WHEN "cnapi.dc" IS NULL THEN 1 ELSE 0 END, "cnapi.dc" DESC) AS z__pivot_col_rank FROM (
SELECT
DATE(cnapi."DATE" ) AS "date",
cnapi."DCENTER" AS "dc",
coalesce(COUNT(*),0) AS "CNcount"
FROM smartdc.cnapi AS cnapi
full join smartdc.datacenters
on smartdc.datacenters.name = cnapi."DCENTER"
WHERE
(((cnapi."DATE" ) >= ((SELECT (DATE_TRUNC('month', DATE_TRUNC('day', CURRENT_TIMESTAMP AT TIME ZONE 'UTC')) + (-2 || ' month')::INTERVAL))) AND (cnapi."DATE" ) < ((SELECT ((DATE_TRUNC('month', DATE_TRUNC('day', CURRENT_TIMESTAMP AT TIME ZONE 'UTC')) + (-2 || ' month')::INTERVAL) + (3 || ' month')::INTERVAL)))))
GROUP BY 1,2) ww
) bb WHERE z__pivot_col_rank <= 16384
) aa
) xx
) zz
WHERE z___pivot_row_rank <= 5000 OR z__pivot_col_ordering = 1 ORDER BY z___pivot_row_rank
;;
}
measure: count {
description: "Number of distinct objects returned in query"
type: count
drill_fields: [detail*]
}
dimension: cnapi_date_date {
description: "CNapi.date for the data"
type: date
sql: ${TABLE}."cnapi.date_date" ;;
}
dimension: cnapi_dc {
description: "CNapi.dc"
type: string
sql: ${TABLE}."cnapi.dc" ;;
}
dimension: cnapi_count {
description: "CNapi.count number of objects returned"
type: string
sql: ${TABLE}."cnapi.count" ;;
}
dimension: z__pivot_col_rank {
description: "The DENSE_RANK of the z__min_rank"
type: string
sql: ${TABLE}.z__pivot_col_rank ;;
}
dimension: z___rank {
description: "The RANK of the CNapi.date"
type: string
sql: ${TABLE}.z___rank ;;
}
dimension: z___min_rank {
description: "The min RANK of z__rank"
type: string
sql: ${TABLE}.z___min_rank ;;
}
dimension: z___pivot_row_rank {
description: "The DENSE_RANK of z___min_rank"
type: string
sql: ${TABLE}.z___pivot_row_rank ;;
}
dimension: z__pivot_col_ordering {
description: "RANK of z__pivot_col_rank"
type: string
sql: ${TABLE}.z__pivot_col_ordering ;;
}
set: detail {
fields: [
cnapi_date_date,
cnapi_dc,
cnapi_count,
z__pivot_col_rank,
z___rank,
z___min_rank,
z___pivot_row_rank,
z__pivot_col_ordering
]
}
}