大家好,我是程序员柏风,AI 最全的 Vibecoding 学习地图 http://coderoadmap.cn 作者。
综合练习
串联本 track 概念:为 CodeRoadMap cf_track / cf_lesson 设计一条 每日批 ETL DAG 草图,含 staging、维度、质量检查与失败告警。
学习目标
- 完成从源表到 mart 的端到端设计方案
- 画出 Airflow DAG 任务依赖
- 列出 dbt models 与 tests 清单
项目:tracks 每日 ETL
业务目标
mart 表 mart_track_daily 供运营查看:
- 每门课程 lesson 数量
- 所属 category、level
- 数据日期
report_date
源表(MySQL OLTP)
| 表 | 关键字段 |
|---|---|
cf_track | id, slug, title, category, level, updated_at |
cf_lesson | id, track_id, slug, duration |
分层交付物
1. stg_coderoadmap__tracks # 增量 Extract
2. stg_coderoadmap__lessons
3. dim_track # SCD1 维表
4. mart_track_daily # 按 report_date 快照
Airflow DAG 草图
start
→ extract_tracks (JDBC 增量,水位 updated_at)
→ extract_lessons
→ dbt_run_staging (dbt run --select staging.*)
→ dbt_run_marts (dbt run --select mart_track_daily)
→ dbt_test (dbt test)
→ notify_slack (失败/on_failure)
end
schedule: @daily,catchup=False,重试 2 次。
质量断言(至少 3 条)
-
dim_track.track_idunique + not_null -
mart_track_daily.lesson_count >= 0 - staging 最大
updated_at在 26 小时内
验收清单
- 文档含 DAG 依赖图,说明 Extract SQL 与幂等 Load
- 标注查询应在只读副本执行
- README 链到 /roadmaps/data-engineer 已覆盖节点
选做:Debezium + kafka-essentials CDC;PR 上 dbt test(github-actions-essentials)。
练习
- 提交 DAG 草图 + 表结构说明(不要求真跑 Airflow)
- 用 SQL 写出
mart_track_daily的 SELECT 逻辑 - 在
/tracks/data-engineer-essentials回顾 12 课,勾选 /roadmaps/data-engineer 对应节点
小结
tracks 每日 ETL = Extract 增量 + dbt 分层 + 质量门禁 + 编排依赖;本 track 闭环。 深入 SQL 见 sql-essentials,事件流见 kafka-essentials,继续 /roadmaps/data-engineer 高级节点。