cswork / libraryOpen practice workspace

Coding questions · Meta

Identify Users Interested in Group Video Calls

This question evaluates a data scientist's ability to perform SQL-based event-level data manipulation, aggregation, joins, and user-level feature derivation from call logs and user attribute tables.

video_calls

caller | recipient | ds | call_id | duration

u1 | u2 | 2023-09-01| c100 | 320

u3 | u4 | 2023-09-01| c101 | 0

u2 | u1 | 2023-09-02| c102 | 180

dim_all_users

user_id | age_bucket | country | primary_os | dau_flag | ds

u1 | 25-34 | US | iOS | 1 | 2023-09-01

u2 | 35-44 | IN | Android | 1 | 2023-09-01

u3 | 18-24 | US | Android | 0 | 2023-09-01

Scenario

Using call-level logs and user attributes, estimate user interest in group video calls.

Question

Write SQL to identify users who appear interested in group video calls using only the tables below.

Hints

Derive number of unique recipients per caller per day and filter callers exceeding a threshold.

Identify Users Interested in Group Video Calls

Using the call-level logs and user attributes, write SQL to identify users who appear interested in group video calls. Define an interested user as a caller who, on a given day (ds), contacted at least 2 unique recipients. Return one row per (user, ds) with the user's attributes and the number of unique recipients.

Table video_calls

columntypeconstraints
callerVARCHAR(50)NOT NULL
recipientVARCHAR(50)NOT NULL
dsDATENOT NULL
call_idVARCHAR(50)PRIMARY KEY, NOT NULL
durationINTEGERNOT NULL

Sample data:

call_idcallerdsdurationrecipient
c100u12023-09-01320u2
c101u32023-09-010u4
c102u22023-09-02180u1

Table dim_all_users

columntypeconstraints
user_idVARCHAR(50)NOT NULL
age_bucketVARCHAR(10)NOT NULL
countryVARCHAR(2)NOT NULL
primary_osVARCHAR(20)NOT NULL
dau_flagINTEGERNOT NULL
dsDATENOT NULL

Sample data:

age_bucketcountrydau_flagdsprimary_osuser_id
25-34US12023-09-01iOSu1
35-44IN12023-09-01Androidu2
18-24US02023-09-01Androidu3

Expected output

Return the list of callers (with user attributes) who, on a given day (ds), contacted at least 2 unique recipients, indicating interest in group video calls. For the provided sample data, no caller contacted 2 or more unique recipients on the same day, so the result is empty.

Hints

  1. First aggregate the call logs by caller and ds to count distinct recipients.
  2. Use COUNT(DISTINCT recipient) grouped by caller and ds; filter where this count is at least 2.
  3. Join the filtered caller-day pairs to dim_all_users on user_id and ds to enrich with user attributes.