# The exercise builds a complete first quality gate as a SQL assertion wired into a DAG

Canonical URL: <https://datadriven.io/problems/the-exercise-builds-a-complete-first-quality-gate-as-a-sql-a-880cdfc0>

Domain: Pipeline Design · Difficulty: medium

## Problem

The exercise builds a complete first quality gate as a SQL assertion wired into a DAG. The target table is mart.daily_orders, produced once per day at 2am. The assertion is that today's row count must fall between 50 percent and 200 percent of the same-day-of-week average over the trailing 8 weeks. The gate is a SQL query the orchestrator runs after the transform; pass lets downstream proceed, fail halts the DAG. Build the gate by adding the orchestrator that runs the transform on schedule, a quality-check transform whose name states the SQL assertion (range and baseline window), and the failure path: when the gate fails, the DAG halts and a paging destination notifies on-call.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/the-exercise-builds-a-complete-first-quality-gate-as-a-sql-a-880cdfc0)
- [System Design Interview Questions](https://datadriven.io/data-engineering-system-design)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.