Flatten Nested Firebase Analytics Events Into a Pandas DataFrame
Last updated: November 29, 2026
Quick Overview
Firebase and GA4 export events as nested JSON with a list of typed event parameters. Flatten them into one row per event with a column per parameter, converting microsecond timestamps and typed values correctly.
0
0
0 solved
Firebase and GA4 export events as nested JSON with a list of typed event parameters. Flatten them into one row per event with a column per parameter, converting microsecond timestamps and typed values correctly.
Anyone who has used the Firebase BigQuery export has fought the event_params array. This take-home style task checks that you handle the key and typed-value structure, missing nested objects and integer values exported as strings, and that the output is analysis ready.
What the Interviewer Expects
- Pick the populated typed value among string, int, double and float
- Convert int values that arrive as strings
- Convert microsecond epoch timestamps to timezone-aware datetimes
- Handle missing device or app_info objects without crashing
- Optionally restrict to a whitelist of parameters to control width
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you write the equivalent query in BigQuery with UNNEST?
- Thousands of distinct parameter keys exist. How do you avoid a 5000 column frame?
- How would you validate the flattened output against the raw counts?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Each raw event has event_name, user_pseudo_id, event_timestamp (microseconds since epoch, sometimes a string), optional device.operating_system and app_info.version, and event_params: a li...
Approach
Iterate events once and build plain dicts, then make a DataFrame. pd.json_normalize handles nested dicts well, but the params list is a key-value array that needs pivoting, so an explicit loop is cl...