Recompute Only Downstream Pipeline Stages After Upstream Changes
Last updated: November 29, 2026
Quick Overview
A warehouse pipeline is a DAG of tables where an edge [a, b] means table b is computed from table a. Given the DAG and a set of tables whose source data changed, return the tables that must be recomputed, in an order where each table comes after every affected table it reads from.
Meta
November 29, 20260
0
0 solved
A warehouse pipeline is a DAG of tables where an edge [a, b] means table b is computed from table a. Given the DAG and a set of tables whose source data changed, return the tables that must be recomputed, in an order where each table comes after every affected table it reads from.
A Meta onsite question for data engineering roles, modeled on backfilling Hive or Presto tables after an upstream fix. The interviewer is checking that you restrict the topological sort to the affected subgraph, with in-degrees counted only from affected parents, rather than recomputing the whole warehouse.
What the Interviewer Expects
- Find the affected set with a forward BFS from the changed tables
- Compute in-degrees using only edges inside the affected set
- Topologically sort that induced subgraph
- Keep cost proportional to the affected subgraph, not the whole DAG
- Discuss running independent tables in parallel
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you group the output into parallel waves to minimize backfill wall time?
- What if some tables are partitioned by date and only some partitions changed?
- How would you skip a table whose recomputed output turns out identical to the old one?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
edges[a, b]andchanged, a list of tables. - Output: all tables reachable from
changed(including them), ordered so that for any edgea -> bamong them,acomes first. - The DAG ...
High-Level Design
Two phases:
- Affected set. BFS from every changed table along outgoing edges. Anything reached must be recomputed.
- Ordering. Run Kahn's algorithm on the induced subgraph. The key detail:...