forked from llooker/demo_segment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_Bb_page_facts.view.lkml
57 lines (51 loc) · 1.4 KB
/
_Bb_page_facts.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
view: page_facts {
derived_table: {
sortkeys: ["timestamp"]
distribution: "tenantbase_visitor_id"
sql_trigger_value: select count(*) from ${mapped_events.SQL_TABLE_NAME} ;;
sql: SELECT
e.event_id AS event_id
, e.tenantbase_visitor_id
, e."timestamp"
, CASE
WHEN DATEDIFF(seconds, e."timestamp", LEAD(e."timestamp") OVER(PARTITION BY e.tenantbase_visitor_id ORDER BY e."timestamp")) > 30*60 THEN NULL
ELSE DATEDIFF(seconds, e."timestamp", LEAD(e."timestamp") OVER(PARTITION BY e.tenantbase_visitor_id ORDER BY e."timestamp")) END AS lead_idle_time_condition
FROM ${mapped_events.SQL_TABLE_NAME} AS e
;;
}
dimension: event_id {
hidden: yes
primary_key: yes
sql: ${TABLE}.event_id ;;
}
dimension: duration_page_view_seconds {
type: number
sql: ${TABLE}.lead_idle_time_condition ;;
}
dimension: is_last_page {
type: yesno
sql: ${duration_page_view_seconds} is NULL ;;
}
dimension: tenantbase_visitor_id {
hidden: yes
type: string
sql: ${TABLE}.tenantbase_visitor_id ;;
}
dimension_group: timestamp {
hidden: yes
type: time
datatype: timestamp
timeframes: [
raw,
time,
date,
month,
day_of_week,
year
]
sql: ${TABLE}."timestamp" ;;
}
set: detail {
fields: [event_id, duration_page_view_seconds]
}
}