Blog.
Capstone: backfill and the run report
The module's exam: re-running a past week safely (only possible because of bronze, keys, and gates) and the three numbers that prove a run was healthy.
Read →Serving the gold layer
Stage 4: publishing a pre-aggregated, date-partitioned gold table that DuckDB queries in place — speed designed in at publish time, not bought with a bigger server.
Read →Orchestration: the DAG runs the show
The layer that runs the stages in order, on a schedule, with retries: an Airflow DAG for the station pipeline, and what catchup=False protects you from.
Read →Incremental loads and idempotency
Process only what's new, and make re-running a window harmless: the dedupe key, keep='last', and the two-run test every pipeline must pass.
Read →Spatial enrichment: points meet polygons
Stage 3 continues: a spatial join attaches each station's county, so gold can aggregate by place — and the unmatched rows become a quality signal.
Read →Data quality gates: fail loud, fail early
A written contract for your data — columns, types, ranges, uniqueness — enforced between silver and gold with pandera, so bad data stops the run instead of reaching a map.
Read →Clean and standardize: the silver layer
Stage 3: turning nested raw GeoJSON into a flat, typed table with a geometry column and a declared CRS — the silver layer every later stage can trust.
Read →Land it raw: the bronze layer
Stage 2: saving API responses byte-for-byte, partitioned by day, before anyone cleans anything — the bronze layer as the pipeline's memory.
Read →Ingesting from an API: paginate, don't guess
Stage 1 of the pipeline: fetching a day of weather observations from the National Weather Service API — User-Agent, time windows, and following pagination links.
Read →Anatomy of a pipeline: ELT, stage by stage
One pipeline, four stages: extract, land raw, transform, serve — and why modern lakes load first and transform second (ELT).
Read →Spatial indexing: geohash and H3
Cell IDs as an index: geohash strings where a shared prefix means nearby, and H3 hexagons with equal-distance neighbours — one key to partition, group and join by place.
Read →Cloud-Optimized GeoTIFFs: read only the pixels you need
A GeoTIFF reorganised for the cloud: internal tiles plus built-in overviews, so a reader fetches only the pixels it needs instead of downloading the whole file.
Read →Raster vs. vector: grids and shapes
The two shapes of geospatial data: vector for discrete features (stations, counties), raster for continuous fields (temperature, rainfall) — and how to tell which one you have.
Read →Apache Sedona: Spark, but spatial
Sedona gives Spark a Geometry type, ST_ functions and real spatial joins — the SQL from Lesson 22, running across a cluster on GeoParquet files.
Read →Partition by place: spatial partitioning with geohashes
Lesson 15's partitioning trick, but for space: a geohash prefix becomes the partition key, so a query over one area reads only that area's folders.
Read →GeoParquet: Parquet that knows where things are
Parquet plus a geometry column: to_parquet on a GeoDataFrame writes GeoParquet — WKB geometry plus CRS and bounding-box metadata in the footer, readable by any Parquet engine.
DuckDB goes spatial: no server, just a file
INSTALL spatial; LOAD spatial; turns DuckDB into a local spatial engine, and ST_Read queries a GeoJSON file as if it were a table — nearest stations, no server.
Near me, in SQL: spatial filters with ST_DWithin
The spatial version of a WHERE filter: ST_DWithin finds every station within a distance of a point — longitude first, SRID 4326, and a spatial index doing the fast lookup.
Read it in, write it out: read/write pipelines
The full pipeline shape in four lines: spark.read.csv raw data in, transform it, df.write.partitionBy("region").parquet clean data out — and read it back with spark.read.parquet.
Join first, then summarize: aggregations + joins
Most PySpark summarizing is two moves in one order: join readings to station metadata on station_id, then groupBy + agg to one summary row per region.
Nothing runs until you say so: transformations vs. actions
Transformations like filter and withColumn only build a plan — actions like show and count are what actually run it. Why laziness lets Spark optimize, and why collect() on a huge table can crash your job.
Your first Spark job: SparkSession + DataFrames
PySpark starts here: one SparkSession entry point and a DataFrame — a pandas-like table that runs across a cluster instead of one machine.
Read →Only load what's new: incremental ingestion
Re-reading the whole source every run is the most expensive habit in data engineering. The watermark pattern — load only rows newer than MAX(recorded_at) — plus what watermarks can't see, and where CDC takes over.
Parquet plus a ledger: open table formats
Delta Lake, Apache Iceberg, and Hudi add a transaction ledger on top of the same Parquet files. MERGE INTO upserts, ACID on the lake, time travel, and compaction — the fix for the small-files problem.
Only read the folders you need: partitioning
Partitioning organizes the lake’s folder into Hive-style subfolders by the columns you filter on. PySpark partitionBy, partition pruning that skips ~119 of 120 folders, rules of thumb, and the small-files problem.
Your table is a folder of files: Parquet
The data-lakes arc begins: a lake is files on object storage, and Parquet is the default file. Columnar storage, column pruning with columns=[...], built-in compression, a typed schema in the file, and the DuckDB connection.
All or nothing: transactions
Transactions wrap multi-step writes into one atomic unit: BEGIN … COMMIT, ROLLBACK when it fails. The ACID promise, why pipelines wrap their writes, and the Delta Lake connection.
Stop storing the same fact twice: normalization
Normalization means storing each fact once: splitting the station/region design into two tables linked by a foreign key. The 1NF/2NF/3NF rundown, update anomalies, why warehouses deliberately denormalize, and the DRY bridge.
Read →Finding rows without reading everything: indexes
An index is the database’s book index: a sorted lookup structure on a column so filters jump straight to matching rows. CREATE INDEX on the columns you filter, join, and sort on — plus the write-cost tradeoff, and the Python dict bridge.
The IDs that hold tables together: primary and foreign keys
PRIMARY KEY gives every row a unique identity; REFERENCES turns the join contract between two tables into a rule the database enforces — so a bad row fails loudly at insert time instead of breaking a dashboard later.
Folders inside the database: schemas
One database can hold hundreds of tables — schemas are the named folders that keep them organized. CREATE SCHEMA, the schema.table convention, and how teams split raw, weather, and geospatial tables into separate namespaces.
Ranking rows without collapsing them: window functions
GROUP BY collapses rows into one per group — window functions keep every row and add a column computed across its peers. RANK() within a region, the OVER () marker, and the top-N-per-category pattern.
Nesting queries with subqueries
A query inside a query: the inner one runs first and feeds its result to the outer one. The two pandas steps you do today — compute a list, then .isin() it — as one statement in the warehouse.
Combining tables with JOIN
Facts in one table, context in another — JOIN stitches them together on a shared key. Pandas .merge(), done inside the warehouse.
Filtering groups with HAVING
WHERE filters rows before grouping; HAVING filters groups after aggregation. And why WHERE COUNT(*) >= 5 is invalid — which is exactly why HAVING exists.
One summary per group with GROUP BY
Aggregates collapse a whole table into one number — GROUP BY collapses it into one number per bucket. The per-country, per-day, per-category breakdown behind every dashboard.
Read →Summarizing data with COUNT, SUM, and AVG
How many, how much, on average: the three aggregate functions that turn a million rows into a single dashboard number.
Read →Sorting and taking the top N with ORDER BY and LIMIT
The top-N pattern: sort descending, keep a few rows. Leaderboards, latest records, biggest tables — it all starts here.
Read →Reading data with SELECT and WHERE
The first thing you do with any new table: pick columns, filter rows. SELECT is the column list, WHERE is the row filter — and it maps exactly onto pandas.
Read →