Pattern 20 — Two-Node Dependency DAG
Class: Create (both nodes) | Test: test_cookbook_20_two_node_dag
When to use
Build a two-level analytics pipeline where a summary stream table depends on a base aggregation stream table.
Migration files
-- migrations/streams/c20_totals.sql
-- @aqueduct:schedule = "30s"
SELECT id, SUM(amount) AS total FROM raw_c20 GROUP BY id;
-- migrations/streams/c20_summary.sql
-- @aqueduct:schedule = "1m"
-- @aqueduct:depends_on = ["public.c20_totals"]
SELECT COUNT(*) AS num_customers FROM public.c20_totals;
Plan output
+ c20_totals [create] level 0
+ c20_summary [create] level 1 (depends on c20_totals)
Notes
aqueductalways applies nodes in topological order.c20_totalsis created beforec20_summaryregardless of file order inmigrations/streams/.- Use
@aqueduct:depends_onto declare explicit dependencies when the planner cannot infer them from schema-qualified names in the SQL.