Data Engineering Integrations
Lesson opener
In one line: An analytics load copies API data into a store you can report on, and it keeps the counts that prove the copy is complete.
Why it matters: Northline's dashboard showed 900 units shipped. The ERP had 960 invoiced and 1,100 booked. The load had stopped after the first page and still marked the batch successful. Purchasing trusted the dashboard.
Before this lesson: Webhooks and event-driven automation.
What you will be able to do
- Separate ETL from ELT without naming a product as the definition.
- Describe an API ingestion that pages until the documented end.
- Distinguish a batch window from a single call.
- Reject a batch whose row counts do not reconcile.
Prerequisites
Lessons 6 to 8. Figures are illustrative. This lesson does not require a particular warehouse product.
ETL, ELT, ingestion, batch, monitoring
ETL (extract, transform, load): you change the shape of the data before it lands in the analytics store. Northline sums bin quantities into one on_hand before the load, because the dashboard's contract is one number per SKU.
ELT (extract, load, transform): you land the API payload first, then transform inside the analytics store. Northline lands the raw receipt events, then builds the daily shipped total. Use ELT when you need to re-run the transform without calling the API again. Use ETL when the analytics store must not hold the raw payload, for example when the payload contains a field the analytics role is not allowed to store.
API ingestion is the extract. It uses the client rules from lesson 6: timeout, documented pagination, retries only when safe. The extract records rows_read.
Batch processing is one bounded run: a business date, or a watermark such as "receipts with occurred_at after the last success." A batch has a start, an end, and a result. An open-ended loop is not a batch.
Monitoring for this lesson is four numbers, written on the batch:
rows_readfrom the API.rows_landedin the store.rows_rejectedby validation.lag, the age of the newest record compared with the batch clock.
Northline's illustrative rule: a batch is successful only when rows_read = rows_landed + rows_rejected and rows_rejected is listed by reason. A dashboard does not refresh on a failed batch. The rule is Northline's choice, not an industry law.
def batch_result(rows_read, rows_landed, rows_rejected):
if rows_read != rows_landed + rows_rejected:
return "failed"
if rows_rejected:
return "completed_with_rejects"
return "completed"
assert batch_result(100, 100, 0) == "completed"
assert batch_result(100, 98, 2) == "completed_with_rejects"
assert batch_result(100, 90, 0) == "failed"The 1,100 / 960 / 900 story from the opener is three different facts: booked, invoiced, and shipped. They are not one number with a load error. Name the fact on the dashboard. A short page is a different defect: rows_read would be smaller than the ERP count for that same fact.
Teacher walkthrough: one night of receipts
Illustrative. The ERP lists 15 receipts for 30 September. Page size is 10. Page 2 has 5 and next_page is null.
- Extract reads 10, then 5.
rows_readis 15. - One receipt fails validation because
qtyis missing.rows_rejectedis 1.rows_landedis 14. 15 = 14 + 1, so the status iscompleted_with_rejects. The rejected id is on the list a person sees in the morning.- The shipped dashboard reads the landed table, and its title says "landed receipts," not "all ERP receipts."
- Validation: a person counts 15 receipts in the ERP for that date. The batch record shows 15, 14, and 1. A batch that read only 10 is
failedif it claimed the date was complete, because 10 does not equal 10 landed plus 0 rejected when 5 unread receipts remain. Count unread pages as not read.
A second workplace case
A webhook lands events all day (lesson 8). The batch each night reconciles event counts with a pull of that date. The pull is the completeness check. The webhook is the freshness path. If the pull reads 15 and the event table holds 14, the batch status is failed until the missing event is fetched. Do not average the two counts.
Failure example: success with a short page
Symptom: The job logs "OK" after page 1. The dashboard is 10 receipts short. The on-call sees a green mark.
Diagnosis: Success was "the HTTP status was 200," not "the date was fully read." The root cause is a batch result that ignores rows_read against the source count.
Correction: Ask the ERP for the count of receipts in the window, or walk pages until next_page is null and then compare. Mark the batch failed when the numbers disagree. Do not refresh the dashboard.
Validation: Remove page 2 in a test. The batch status is failed. The previous day's dashboard remains the one on screen.
Guided practice: score two batches
Scenario: Figures are illustrative.
- Batch A: read 40, landed 40, rejected 0. Source count for the window is 40.
- Batch B: read 40, landed 37, rejected 0. Source count is 40.
Hints:
- Use
batch_resulton the three job numbers. - Then compare
rows_readwith the source count.
Complete solution:
Batch A is completed, and 40 equals the source count. The dashboard may refresh. Batch B is failed because 40 does not equal 37 + 0. Three rows were dropped after the read, or the landed write lied. Either way the batch is not successful. Do not publish 37 as the full day. Validation is the equation on the batch record and the source count beside it.
Independent practice
Describe one load from an API into a report store.
Acceptance criteria:
- You say ETL or ELT and why, including whether raw payloads are allowed in the store.
- You name the batch window.
- You list
rows_read,rows_landed, androws_rejected. - You state the equation that marks success.
- You say what the dashboard does when the equation fails.
- You name the business fact the column represents, so booked is not labelled shipped.
Common mistakes
- Marking a batch successful because the first page returned 200.
- Hiding rejected rows so the equation looks clean.
- Calling three different ERP facts one "sales number."
- Loading a bank-account field into a store whose role forbids it.
Quick check
- When does this lesson choose ELT over ETL?
- What is a batch, as opposed to an open loop?
- What equation marks a Northline batch as not failed?
- Batch numbers are read 100, landed 90, rejected 0. What is the result?
- Why did 1,100, 960, and 900 not automatically mean a short page?
Answers:
- When you must keep the raw payload and re-run the transform without calling the API again, and the store is allowed to hold that payload.
- A bounded run with a window, a start, an end, and a result.
rows_read = rows_landed + rows_rejected, and the read matches the source count for that window.failed.- They can be three facts: booked, invoiced, and shipped. Name the fact. A short page is a separate check against one fact's source count.
Lesson summary
Extract with the client rules you already have. Transform before or after the load on purpose. A batch is done only when the counts reconcile and the dashboard's fact is named.
Bridge to the next lesson
People will ask an assistant to call these APIs. The next lesson is how a tool call is proposed, checked, and sometimes held for a person before it writes.