# Syllabus học GCP Data engineer

## Phase 0: Cloud + Linux + Python + SQL nền tảng (2-3 tuần)

### Linux & Shell

*   Bash scripting: pipe, redirect, xargs, sed/awk cơ bản
    
*   cron, systemd timer (hiểu cách schedule job ngoài Cloud Composer)
    
*   Networking cơ bản: DNS, TCP/IP, curl/netcat để debug connectivity
    

### Python cho Data Engineering

*   **pandas** (xử lý dữ liệu vừa), **pyarrow** (columnar, tương tác Parquet)
    
*   **pydantic** - schema validation, type-safe data contracts
    
*   **requests**/**httpx** - gọi API, ingest từ REST source
    
*   Packaging: **poetry** hoặc **uv**, virtualenv
    
*   Testing: **pytest**, fixtures, mocking external services
    

### GCP nền tảng (giữ từ syllabus v1)

*   IAM, VPC, resource hierarchy, org policy, billing
    
*   gcloud CLI + Cloud Shell
    

**Thực hành:** Viết 1 script Python (pydantic-validated) đọc CSV, validate schema, ghi ra Parquet bằng pyarrow, có test pytest kèm theo, chạy qua cron.

## Phase 1: Advanced SQL + Data Modeling (3-4 tuần)

### Advanced SQL

**Query Optimization**

*   Đọc execution plan (BigQuery: query explanation, EXPLAIN)
    
*   Predicate pushdown, partition pruning
    
*   Join strategies: broadcast join vs shuffle join, khi nào BigQuery chọn cái nào
    
*   Shuffle cost và cách giảm thiểu (denormalize, cluster theo join key)
    

**Analytic SQL**

*   Window functions: ROW\_NUMBER, RANK, LAG/LEAD, running totals
    
*   Recursive CTE (hierarchical data, org chart, bill-of-materials)
    
*   Gaps and islands problem
    
*   Cohort analysis, retention analysis bằng SQL thuần
    

**BigQuery SQL Internals**

*   Slots - đơn vị compute, cách BigQuery phân bổ
    
*   Execution stages: đọc query plan chi tiết (stage → shuffle → output)
    
*   Storage engine: Capacitor (columnar format), Colossus (storage layer), Dremel (execution engine)
    

**Data Modeling SQL - thực hành viết**

*   SCD Type 1 (overwrite), Type 2 (versioning + effective\_date), Type 3 (previous value column)
    
*   Fact table (transaction fact, periodic snapshot fact, accumulating snapshot fact)
    
*   Dimension table + snapshotting pattern
    

### Data Modeling - lý thuyết Kimball & hiện đại

**Kimball Dimensional Modeling**

*   Fact vs Dimension, grain (mức chi tiết) - quyết định quan trọng nhất khi modeling
    
*   Conformed dimension (dùng chung nhiều fact table)
    
*   Degenerate dimension (vd: order\_id nằm trong fact, không có dimension riêng)
    
*   Junk dimension (gom các flag/indicator rời rạc)
    

**Slowly Changing Dimensions - đầy đủ**

*   Type 0: giữ nguyên giá trị gốc, không update
    
*   Type 1: overwrite, mất lịch sử
    
*   Type 2: thêm row mới + effective\_date/end\_date/is\_current flag
    
*   Type 3: thêm cột previous\_value
    

**Data Vault (tổng quan, đủ để nhận biết khi nào nên dùng)**

*   Hub (business key), Link (relationship), Satellite (descriptive attribute + history)
    
*   Khi nào Data Vault hợp lý hơn Kimball (nhiều nguồn, cần audit trail cực mạnh, insurance/banking)
    

**Lakehouse Modeling (Medallion Architecture)**

*   Bronze (raw, immutable) → Silver (cleaned, conformed) → Gold (business-level aggregate)
    
*   Áp dụng pattern này lên GCS + BigQuery
    

**Dự án Phase 1:** Modeling lại 1 dataset thật (vd: e-commerce order data) theo cả 3 kiểu: star schema Kimball với SCD Type 2, rồi thử dựng Bronze/Silver/Gold trên cùng dataset để so sánh.

## Phase 2: BigQuery (2 tuần)

*   Kiến trúc: Dremel execution engine, Colossus storage, Jupiter network, Borg resource management (tổng quan để hiểu vì sao BigQuery serverless nhanh)
    
*   Partitioning: time-unit, ingestion-time, integer-range - chọn đúng loại
    
*   Clustering: multi-column clustering, tương tác với partition
    
*   Materialized views: incremental refresh, khi nào BQ tự động rewrite query
    
*   BI Engine: in-memory acceleration, khi nào kích hoạt
    
*   Query cost control: bytes scanned, dry-run estimate, custom quotas
    
*   BigQuery Editions (Standard/Enterprise/Enterprise Plus) + slot reservation, autoscaling reservation
    
*   Authorized views, row-level security, column-level security (policy tags)
    

**Thực hành:** Tối ưu 1 query chậm thật (từ dataset public) - trước/sau khi thêm partition + clustering, so sánh bytes scanned và thời gian chạy.

## Phase 3: Storage & Lakehouse Internals (2 tuần)

### File Format Internals

*   **Parquet**: columnar layout, row group, page, predicate pushdown ở file level
    
*   **ORC**, **Avro** (schema evolution, dùng nhiều trong Kafka)
    
*   Compression: Snappy (nhanh), Gzip (nén tốt hơn, chậm hơn), ZSTD (cân bằng)
    

### Table Format

*   **Apache Iceberg**: snapshot, manifest file, schema evolution, time travel - BigQuery đã hỗ trợ Iceberg qua BigLake
    
*   **Delta Lake**: transaction log, ACID trên data lake
    
*   **Apache Hudi**: upsert-optimized, dùng nhiều cho CDC pipeline
    
*   So sánh 3 table format, khi nào chọn cái nào trên GCP (BigLake + Iceberg là hướng GCP đang đẩy mạnh)
    

### Storage & Data Layout Design

*   Partitioning ở file-system level (Hive-style partition)
    
*   File size optimization (tránh small file problem)
    
*   Data layout cho cost + performance trade-off
    

**Dự án Phase 3:** Dựng 1 Iceberg table qua BigLake trên GCS, thử time travel + schema evolution.

## Phase 4: Batch Processing (3 tuần)

### Apache Beam & Dataflow

*   PCollection, PTransform, pipeline construction
    
*   Dataflow Flex Templates, autoscaling, Dataflow Prime
    

### Apache Spark

**Core**

*   RDD (nền tảng), DataFrame, Dataset API
    
*   Lazy evaluation, transformation vs action
    

**Internals**

*   DAG scheduler, stages, tasks
    
*   Catalyst optimizer (query plan optimization)
    
*   Tungsten (memory & code generation optimization)
    

**Optimization**

*   Partitioning trong Spark, repartition vs coalesce
    
*   Data skew - nhận diện và xử lý (salting key)
    
*   Broadcast join threshold tuning
    

**Structured Streaming** (cầu nối sang Phase 5)

### Dataproc

*   Ephemeral vs persistent cluster
    
*   Dataproc Serverless for Spark
    
*   Khi nào Dataproc/Spark hợp lý hơn Dataflow/Beam (migrate từ Hadoop on-prem, cần Spark-specific library)
    

**Dự án Phase 4:** Viết cùng 1 job transform bằng cả Beam/Dataflow VÀ PySpark/Dataproc Serverless, so sánh performance, cost, độ phức tạp code.

## Phase 5: Streaming Systems (2-3 tuần)

### Streaming Theory

*   Delivery semantics: **At-most-once**, **At-least-once**, **Exactly-once** - cách đạt được exactly-once trong Beam/Dataflow (idempotent sink, deduplication)
    
*   Checkpointing & state management (Beam state API, Spark Structured Streaming checkpoint)
    
*   Event time vs Processing time - tại sao phân biệt này quyết định độ chính xác
    
*   Watermark algorithms: cách hệ thống ước lượng "đã nhận đủ dữ liệu tới thời điểm X chưa"
    
*   Backpressure: điều gì xảy ra khi consumer chậm hơn producer, cách hệ thống tự điều tiết
    
*   Stream-stream join, stream-table join
    
*   Out-of-order events - xử lý bằng allowed lateness + trigger
    

### Hệ thống thực tế

*   Pub/Sub: ordering key, dead-letter topic, schema registry, Pub/Sub Lite vs Standard
    
*   Managed Service for Apache Kafka trên GCP, so sánh sâu với Pub/Sub (ordering guarantee, replay, ecosystem)
    
*   Beam Streaming: windowing (fixed/sliding/session) kết hợp với watermark + trigger thực chiến
    

**Dự án Phase 5:** Xây streaming pipeline có giả lập out-of-order events + duplicate events, chứng minh pipeline đạt exactly-once semantics ở sink.

## Phase 6: Analytics Engineering (2 tuần)

### dbt

*   dbt Core: models, sources, seeds, snapshots
    
*   Tests: schema tests (unique, not\_null, relationships), custom tests
    
*   Macros (Jinja templating) - DRY code
    
*   Incremental models - chiến lược merge/insert\_overwrite cho bảng lớn
    
*   Documentation & lineage tự động (dbt docs generate)
    
*   dbt Cloud vs dbt Core (self-host)
    

### Dataform

*   So sánh trực tiếp dbt vs Dataform: cú pháp, tích hợp BigQuery, khi nào công ty chọn cái nào
    

### BI Layer

*   Looker/Looker Studio: LookML cơ bản, semantic layer
    
*   Kết nối BI tool bên thứ 3 (Tableau, Power BI) qua BigQuery connector
    

**Dự án Phase 6:** Chuyển toàn bộ transform layer (SQL thuần) ở Phase 1 sang dbt models với tests + incremental + docs, generate lineage graph.

## Phase 7: Data Quality & Observability (1-2 tuần)

Mảng bị thiếu hoàn toàn ở v1 ngoài 1 dòng nhắc Great Expectations.

### Data Contracts

*   Schema contract giữa producer-consumer (vd: Protobuf/Avro schema versioning)
    
*   Breaking change detection trong CI
    

### Data Validation

*   **Great Expectations**: expectation suite, checkpoint, data docs
    
*   **Soda** (SodaCL) - validation dạng YAML, tích hợp CI/CD
    

### Data Observability

*   Khái niệm Monte Carlo/Datadog Data Quality (không cần trả phí học tool, hiểu concept: freshness, volume, schema, distribution anomaly detection)
    
*   Áp dụng concept này bằng cách tự xây alerting đơn giản trên GCP (Cloud Monitoring custom metric + log-based alert)
    

### Reconciliation

*   Row count reconciliation giữa source và sink
    
*   Checksum-based validation
    
*   Business validation (vd: tổng revenue theo ngày phải khớp giữa raw và aggregate table)
    

**Dự án Phase 7:** Thêm 1 lớp validation (Great Expectations hoặc Soda) vào pipeline Phase 2/4, có checkpoint fail → dừng pipeline + alert.

## Phase 8: Governance, Security & Platform Engineering (2 tuần)

### Governance & Security

*   Cloud DLP, Dataplex + Dataplex Catalog, CMEK, IAM nâng cao, VPC Service Controls
    

### Terraform cho Data Platform

*   Modules: tách reusable module cho BigQuery dataset, Dataflow job, Composer environment
    
*   Remote state (GCS backend + state locking)
    
*   Multi-environment: workspace hoặc thư mục riêng cho dev/staging/prod
    
*   GitOps: PR-based apply, review trước khi apply lên prod
    

### CI/CD & Promotion Strategy

*   Cloud Build pipeline: test → build → deploy
    
*   Promotion dev → staging → prod có approval gate
    
*   Secret Management: Secret Manager, kết hợp CMEK cho secret encryption
    

### FinOps

*   BigQuery cost model: bytes scanned (on-demand) vs slots (reservation) - khi nào Editions rẻ hơn on-demand
    
*   Dataflow cost: worker type, autoscaling range ảnh hưởng cost thế nào
    
*   Dataproc cost: ephemeral cluster tiết kiệm ra sao so với persistent
    
*   Cost attribution bằng labels, chargeback giữa các team
    
*   Budget enforcement: budget alert, programmatic budget action (tự tắt resource khi vượt ngưỡng)
    

**Dự án Phase 8:** Viết toàn bộ hạ tầng của Capstone (Phase 9) bằng Terraform modules, CI/CD qua Cloud Build, có budget alert + cost label theo team.

## Phase 9: Capstone - Production Data Platform (3-4 tuần)

Xây 1 hệ thống tích hợp **tất cả** các phase trên, không chỉ pipeline đơn giản như v1:

```plaintext
Nguồn: batch files + CDC (Datastream) + streaming events (Pub/Sub)
   → Bronze layer (GCS, raw, Iceberg format qua BigLake)
   → Spark/Dataproc Serverless + Dataflow/Beam xử lý (chọn công cụ theo use case)
   → Silver layer (cleaned, validated bằng Great Expectations/Soda)
   → Gold layer (BigQuery, star schema Kimball + SCD Type 2, quản lý qua dbt)
   → Data Quality checkpoint + reconciliation ở mỗi layer
   → Dataplex Catalog quản lý toàn bộ lineage + governance
   → BQML model + Looker Studio dashboard (row-level security)
   → Cloud Composer orchestrate toàn pipeline, đa environment (dev/staging/prod)
   → Terraform IaC toàn bộ, CI/CD qua Cloud Build với promotion gate
   → Cloud Monitoring + alerting + FinOps dashboard (cost theo team/pipeline)
   → Disaster recovery runbook: multi-region, replication, failover test thật
```

**Deliverable bắt buộc:**

1.  Architecture Decision Record (ADR) - giải thích từng lựa chọn công cụ và trade-off
    
2.  Data dictionary + lineage graph (từ dbt/Dataplex)
    
3.  Runbook vận hành: incident response, cost anomaly response, DR drill
    
4.  Demo end-to-end + chứng minh exactly-once ở streaming layer
    

## Tài nguyên bổ sung

*   SQL/Modeling: sách *The Data Warehouse Toolkit* (Kimball), *Fundamentals of Data Engineering* (Reis & Housley)
    
*   Spark Internals: *Learning Spark* (O'Reilly), Spark UI thực hành trực tiếp
    
*   Streaming Theory: bài báo gốc "Dataflow Model" của Google (Akidau et al., 2015) - nền tảng lý thuyết của Beam
    
*   dbt: dbt Learn (free courses chính thức)
    
*   Data Quality: docs Great Expectations + Soda chính thức
    
*   Iceberg/Delta/Hudi: đọc design doc chính thức của từng project trên GitHub
