internalsGet Pro

Data Engineering · Module 02

SQL for data engineering

Lessons
12
Free
0
Reading
~3 h

Your progress

0 / 12 lessons done

Sign in to track

Lessons

  1. Join pitfalls: duplicated and missing rowsA join that adds or drops rows raises no error. The query runs and the total is quietly wrong. Every table that combines two sources, from revenue by city to the features a model trains on, depends on catching this before someone reads the number.16 min
  2. NULLs and messy values in SQLEvery source a pipeline reads has missing and messy values, and SQL handles them without raising an error. The numbers come out wrong instead: a total that doesn’t add up, an average that is too high, a query that returns nothing.16 min
  3. Window functions: running totals and rankingsAlmost every report a data engineer builds needs a number that depends on other rows: revenue so far this month, the change since yesterday, the top 3 products in each city. Window functions compute these in one pass, and their defaults decide whether ties quietly change the answer.17 min
  4. Sessionization: grouping events into visits with SQLVisits per day, conversion per visit and time on site all come from turning clicks into visits. The SQL is short; the choices inside it, and the clicks that arrive late or twice, decide whether a growth team can trust the numbers.17 min
  5. Pivoting and unpivoting data in SQLFinance asks for grids and partners send grids, but pipelines need rows. Every reporting pipeline turns one shape into the other at least twice, and that turn is where new cities, new statuses and empty cells quietly go missing.16 min
  6. Dates, times and time zones in SQLEvery daily, weekly and monthly number depends on which day each row belongs to. A query that leaves the time zone to the server gives a different revenue on a different machine, and no error says so.17 min
  7. Semi-structured data: querying JSON in SQLApp events, API responses and webhooks arrive as JSON whose fields change with every event type and app release. A query over them never fails when a field is renamed or missing; it returns a smaller number, and only a pipeline that checks will notice.17 min
  8. Recursive queries: hierarchies and graphs in SQLProduct categories, org charts, account hierarchies and data lineage are all stored as rows that point at other rows. Reports need totals at every level, and only a recursive query, or a table built from one, can follow those pointers to any depth.18 min
  9. Deduplication: keeping one row per entityRetries, resent events and repeated loads put the same order or click into a pipeline more than once. Every count and sum built on top depends on keeping exactly one row per entity, and on keeping the same row every time the job runs.17 min
  10. MERGE and upserts: updating tables in placeOnce a table is too big to rebuild every night, a pipeline has to change it in place. The statement that does this is short, and nearly every way it goes wrong is silent: a rerun, a repeated key or a late old change leaves a wrong row and no error.18 min
  11. Writing fast analytical queriesAnalytical queries run over months of data, inside a nightly job with a fixed budget or behind a dashboard someone waits on. The same question can read 1 TB or 20 GB depending on how the SQL is written, and the plan shows which one you wrote.17 min
  12. SQL style, reviews and tests for pipelinesA SQL change raises no error when it is wrong. It runs, and a number moves. Readable queries, a second reader and tests that run before every night are how a team keeps the numbers people rely on right as more people change the SQL.16 min

Practise with

No tools or paper guides for this module yet.

Terms this module teaches 41

Open glossary

Anti join

A join that returns the left rows that have no match on the right.