forked from llooker/demo_segment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Bb_page_facts.view.lkml
56 lines (50 loc) · 1.33 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
view: page_facts {
derived_table: {
sortkeys: ["received_at"]
distribution: "looker_visitor_id"
sql_trigger_value: select count(*) from ${mapped_events.SQL_TABLE_NAME} ;;
sql: SELECT e.event_id AS event_id
, e.looker_visitor_id
, e.received_at
, CASE
WHEN DATEDIFF(seconds, e.received_at, LEAD(e.received_at) OVER(PARTITION BY e.looker_visitor_id ORDER BY e.received_at)) > 30*60 THEN NULL
ELSE DATEDIFF(seconds, e.received_at, LEAD(e.received_at) OVER(PARTITION BY e.looker_visitor_id ORDER BY e.received_at)) 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: looker_visitor_id {
hidden: yes
type: string
sql: ${TABLE}.looker_visitor_id ;;
}
dimension_group: received {
hidden: yes
type: time
datatype: timestamp
timeframes: [
raw,
time,
date,
month,
day_of_week,
year
]
sql: ${TABLE}.received_at ;;
}
set: detail {
fields: [event_id, duration_page_view_seconds]
}
}