-
Notifications
You must be signed in to change notification settings - Fork 42
/
2_mapped_tracks.view.lkml
58 lines (49 loc) · 1.33 KB
/
2_mapped_tracks.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
## Intermediate Table
view: mapped_tracks {
derived_table: {
sortkeys: ["event_id"]
distribution: "looker_visitor_id"
sql_trigger_value: select current_date ;;
sql: select *
, datediff(minutes, lag(received_at) over(partition by looker_visitor_id order by received_at), received_at) as idle_time_minutes
from (
select CONCAT(t.received_at, t.uuid) as event_id
, t.anonymous_id
, a2v.looker_visitor_id
, t.received_at
, t.event as event
, t.uuid
from segment.tracks as t
inner join ${aliases_mapping.SQL_TABLE_NAME} as a2v
on a2v.alias = coalesce(t.user_id, t.anonymous_id)
)
;;
}
dimension: anonymous_id {
sql: ${TABLE}.anonymous_id ;;
}
dimension: uuid {
sql: ${TABLE}.uuid ;;
}
dimension: event_id {
sql: ${TABLE}.event_id ;;
}
dimension: looker_visitor_id {
sql: ${TABLE}.looker_visitor_id ;;
}
dimension_group: received_at {
type: time
timeframes: [time, date, week, month]
sql: ${TABLE}.received_at ;;
}
dimension: event {
sql: ${TABLE}.event ;;
}
dimension: idle_time_minutes {
type: number
sql: ${TABLE}.idle_time_minutes ;;
}
set: detail {
fields: [event_id, looker_visitor_id, received_at_date, event, idle_time_minutes]
}
}