Rebuild Current Page Settings From Sparse Partial Updates
Last updated: November 29, 2026
Quick Overview
Each update to a Facebook Page writes only the fields that changed and leaves the others NULL. Reconstruct the current value of every field (name, category, call to action) per page, taking the latest non-null value for each field independently.
Meta
November 29, 20260
0
0 solved
Each update to a Facebook Page writes only the fields that changed and leaves the others NULL. Reconstruct the current value of every field (name, category, call to action) per page, taking the latest non-null value for each field independently.
Many Meta logging tables store patches rather than full rows. This onsite question checks whether you can coalesce latest non-null values per column, which ordinary latest-row dedupe gets wrong.
What the Interviewer Expects
- Recognizes latest row per page is wrong because fields are NULL in later patches
- Takes the latest non-null value per column independently
- Uses MAX_BY with a filter, or LAST_VALUE IGNORE NULLS, or a running-count grouping trick
- Handles fields that are intentionally cleared (tombstone values)
- Can produce the full filled history, not just the final state
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 represent an intentional clear of a field if NULL means unchanged?
- How would you output the full state as of every update?
- How would this run as an incremental daily snapshot?
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
page_updates(page_id, ts, name, category, cta); NULL means "unchanged". Example for page 1: (t1, Joe Cafe, food, NULL), (t2, NULL, NULL, call), (t3, Joe's Cafe, NULL, NULL), (t4, NULL, restaurant, N...
Approach
Picking the latest row with ROW_NUMBER would return (NULL, restaurant, NULL). Each column needs its own "latest non-null". For only the final state, aggregate with a filter. For a full forward-filled ...