Course
Run the Pipeline
A hands-on 15-lesson advanced SQL course. Build, test, operate, and safely improve a pipeline with your AI coding agent.
You know how to write a query. Now make it safe to run every day.
- Turn a saved query into a pipeline with explicit dependencies, checks, tests, and evidence.
- Choose update strategies that tell when an order happened, when it reached the system, and which dates need repair.
- Give an agent a limited environment, rules it cannot bypass, and enough logs to investigate a failure.
- Ship a governed retail pipeline whose outputs can be reviewed, repaired, and rerun without trusting a confident answer.
How it works
Your coding agent teaches the course. It reads the project, teaches one lesson at a time, asks the quiz questions, and reviews the task after you finish it. These pages are a companion you can use alongside that conversation.
1. Paste this setup prompt into your agent in an empty folder.
You are going to set up and then teach me an interactive SQL course. Do this in order, and show me each command before you run it:
- Check that Git and Bruin are installed (
git --version,bruin version). If Bruin is missing, install it withcurl -LsSf https://getbruin.com/install/cli | sh, then check the version again. - From the empty folder where I want the project to live, run
bruin init --in-place academy-sql-advanced. - Run
bruin validate academy-sql-advanced/pipeline. Then generate the sample data withbruin run academy-sql-advanced/pipeline. The shipped project intentionally fails only onmart.churn_risk; stop if any other asset fails or if validation fails. After the expected failure, confirmordershas 1,212 rows andorder_itemshas 2,895 rows. - Read
academy-sql-advanced/AGENTS.mdandacademy-sql-advanced/course/README.mdso you know how to run the course. - Greet me, show me the 15-lesson syllabus, and tell me to say "next lesson" to begin and "review my work" whenever I finish a task.
After setup, stay in the project root containing .bruin.yml; lesson paths such as pipeline and queries/... are relative to that directory. Do not teach lesson one yet - get set up and hand me the controls. If any command fails unexpectedly, stop and show me the error instead of trying something else.
The default environment is local DuckDB and needs no token. MotherDuck is optional. No lesson requires the cloud path.
2. Say next lesson. The agent teaches the next incomplete lesson, asks its questions one at a time, and gives you the task.
3. Do the task and say review my work. The agent reads the artifact or answer, runs the required checks, and grades it against the lesson rubric.
What you will build
The template is a repeatable retail pipeline with generated input data, staging tables, shared models, and reporting tables. Bruin calls the last group marts. The project is intentionally not clean: validation passes, while the first run fails only at mart.churn_risk so you can investigate a real defect in an earlier table later.
By the capstone, you will have a dependency graph, checks that stop bad output, unit tests, update rules that touch only the dates that changed, a customer history table that keeps old versions, late-data evidence, a dev run, a logging plan, and a written capstone defence. The target is a pipeline whose failures are visible, limited, and explainable.
The four phases
- Build the pipeline - classify operational risk and read the dependency graph.
- Make failure loud - turn audit questions into checks, tests, and controlled failure drills.
- Run it repeatedly - make reruns safe, handle late data, compare filters, and use a separate dev database.
- Operate with an agent - place guardrails at the right layer, investigate the shipped failure, read evidence, and ship the capstone.
Before you start
Take Design the Model first if you have not worked with model contracts, grain, joins, and data quality. This course assumes you can review SQL and focuses on the operational consequences of running it repeatedly.
Before you start
- The intermediate course, Design the Model, or equivalent experience with SQL modeling, joins, grain, and data quality.
- Git, a terminal, an AI coding agent, and a code editor. The setup prompt creates a local DuckDB project with no cloud credentials required.
15 steps
Course outline
Build the pipeline
Turn a query into a reliable graph and classify the risk of each operation.
- 1Query to pipelineMake a recurring pipeline safe to repeat, check, repair, and stop when output is wrong.7 min
- 2SQL changes and approvalDecide which database changes an agent may run and which need review first.12 min
- 3Dependencies and the graphRead the pipeline graph and separate run order from quality checks.10 min
Make failure loud
Turn audit questions into checks, tests, and controlled failure drills.
Run it repeatedly
Make reruns safe, handle late data, compare filters, and use a separate dev database.
- 7Incremental updates and historyUpdate only changed dates, prove reruns are safe, and keep old customer versions.14 min
- 8Late data and backfillsTell when an order happened from when it arrived, then design a limited repair.12 min
- 9Date filters and query costCompare date filters and learn what local scan evidence can tell you about cost.12 min
- 10Dev environmentsGive agent experiments an isolated destination and understand its limits.10 min
Operate with an agent
Investigate failures, preserve evidence, and ship a governed pipeline.
- 11GuardrailsPlace pipeline rules at the layer that can actually enforce them.12 min
- 12Investigate a failureTrace the broken churn-risk asset to the smallest safe fix.12 min
- 13Logs, history, and the billUse structured run evidence and distinguish local logs from warehouse cost history.10 min
- 14Capstone: ship itMake both reporting tables safe to update, test, document, and rerun.30 min
- 15Recap and next stepsKeep the evidence, tests, timestamps, and boundaries that make agent work safe.5 min
Additional resources
Get help & contribute