-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.1 Test Assignment.sql
57 lines (51 loc) · 1.46 KB
/
4.1 Test Assignment.sql
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
# 1 how many test running
--- parameter_name has test_assignment test_id
SELECT distinct parameter_value as test_id
from dsv1069.events
where event_name='test_assignment' and parameter_name='test_id'
# Assignment Event Table
SELECT
event_id,
date(event_time) as day,
user_id,
platform,
max(case when parameter_name='test_id' then cast(parameter_value AS INT) else null end) as test_id,
max(case when parameter_name='test_assignment' then parameter_value else null end) as test_assignment
from dsv1069.events
where event_name='test_assignment'
group by
event_id,
day,
user_id,
platform
order by event_id
# Sanity Check-Assignment
with test_a as (
SELECT
event_id,
date(event_time) as day,
user_id,
platform,
max(case when parameter_name='test_id' then cast(parameter_value AS INT) else null end) as test_id,
max(case when parameter_name='test_assignment' then parameter_value else null end) as test_assignment
from dsv1069.events
where event_name='test_assignment'
group by
event_id,
day,
user_id,
platform
order by event_id
)
select user_id, test_id, count(distinct test_assignment)
from test_a
group by user_id, test_id
order by count(distinct test_assignment) desc
# Sanity Check-Missing Data
SELECT
date(event_time) as day,
parameter_value as test_id,
count(*) as event_rows
FROM dsv1069.events
WHERE event_name='test_assignment' and parameter_name='test_id'
group by test_id, day