Unit 12 Cloud Pipelines Notes
Capstone: End-to-End Pipeline
Build and run a complete cloud data pipeline from scratch — raw file to business report — applying every skill from this course in one unified workflow.
Capstone Objectives
- Create a raw dataset with real-world data quality problems and load it as a SQL table
- Inspect the raw data, apply cleaning rules to remove missing values and standardize text
- Save the cleaned result as a permanent Delta output table
- Run a business aggregation query to produce a regional sales summary
- Simulate the full automated pipeline sequence and articulate each step’s purpose
Create a notebook named Unit12_Capstone_Pipeline in Databricks, language Python, cluster attached. This notebook runs the entire pipeline from start to finish — every cell builds directly on the previous one.
[“Alice”, 500, “west”],
[“Bob”, None, “east”],
[“Charlie”, 700, “north”],
[“Diana”, 650, “west”],
[“Ethan”, None, “south”]
]
spark.createDataFrame(raw_data, [“employee”, “sales”, “region”]) \
.createOrReplaceTempView(“raw_sales”)
The raw dataset has five employees. Two of them — Bob and Ethan — have None in the sales column, representing missing values that arrived from the source system. All region values are lowercase and inconsistent. This is the authentic starting state: messy, incomplete, exactly what a real business file looks like before cleaning. The second part of the cell converts this Python list into a Spark DataFrame with three named columns and registers it as a temporary SQL view called raw_sales — ready for SQL queries in the cells below. No output is shown for this cell.
| employee | sales | region |
|---|---|---|
| Alice | 500 | west |
| Bob | NULL | east |
| Charlie | 700 | north |
| Diana | 650 | west |
| Ethan | NULL | south |
Always inspect before cleaning. This query displays all five rows with all three problems visible: Bob and Ethan’s NULL sales values, and all region values in lowercase. This baseline view serves two purposes — it confirms the data loaded correctly (all five rows are present), and it documents the exact state of the raw data at the point of arrival. In a production pipeline, this output would be captured in the run log as evidence of what the raw file contained before any transformations were applied.
SELECT employee, sales, UPPER(region) AS region
FROM raw_sales
WHERE sales IS NOT NULL;
This is the cleaning query — the heart of the pipeline’s logic. Three operations run simultaneously. WHERE sales IS NOT NULL removes Bob and Ethan’s rows because their sales figures are missing — they cannot contribute to any calculation. UPPER(region) converts all region values to uppercase, eliminating the inconsistent capitalisation. CREATE OR REPLACE TEMP VIEW cleaned_sales AS saves the result of this query as a new temporary view rather than displaying it immediately — the cleaned version is now available for the next steps. No visible output is produced by this cell; the data is ready but not yet shown.
| employee | sales | region |
|---|---|---|
| Alice | 500 | WEST |
| Charlie | 700 | NORTH |
| Diana | 650 | WEST |
Three rows remain — Alice, Charlie, and Diana. Bob and Ethan are gone because their sales values were NULL. All region values are uppercase. This is the moment to verify the cleaning logic worked exactly as intended before saving anything permanently. The row count dropped from 5 to 3 — which is expected and correct. If the count were wrong (4 rows, or 2), something in the cleaning logic would need to be investigated before proceeding. Verifying here costs nothing; discovering an error after writing to the permanent table is far more disruptive.
SELECT * FROM cleaned_sales;
CREATE OR REPLACE TABLE writes the cleaned data to a permanent Delta table named final_sales_report. Unlike the temporary views in Cells 1 and 3, this table persists after the notebook session ends. It lives in the Databricks Catalog — any tool, dashboard, or colleague with access to the workspace can now query final_sales_report directly. REPLACE means that if this pipeline runs again next week with a new file, the table is simply updated rather than duplicated. This single command is the step that transforms the notebook’s output from a session result into a durable business asset.
FROM final_sales_report
GROUP BY region;
| region | total_sales |
|---|---|
| WEST | 1150 |
| NORTH | 700 |
This is the final business output — the reason the entire pipeline exists. GROUP BY region groups the three clean rows by their region value. SUM(sales) adds up the sales figures within each group: Alice (500) and Diana (650) are both in WEST, so the WEST total is 1,150. Charlie (700) is the only employee in NORTH, so the NORTH total is 700. The label AS total_sales names the result column clearly for reporting. This is the table that a weekly sales dashboard would display — built entirely from a raw, messy file that arrived just minutes before in S3, processed automatically, with no manual intervention between file arrival and this clean regional summary.
print(“Step 2: AWS Lambda trigger activated”)
print(“Step 3: Databricks notebook started”)
print(“Step 4: Raw data cleaned”)
print(“Step 5: Final output table created”)
print(“Step 6: Business report ready”)
Each line maps to a component and a unit. Step 1 is the S3 upload from Unit 3. Step 2 is the Lambda trigger from Units 8–9. Step 3 is the Databricks notebook from Units 4–5. Step 4 is the SQL cleaning from Unit 6. Step 5 is the Delta table write from Unit 7. Step 6 is the aggregation report from Unit 7’s GROUP BY query — the output that reaches the business. In a live automated system, Steps 2 through 6 run without any human action after Step 1. The sales manager who uploaded the file on Monday morning finds the regional summary waiting in their dashboard by the time their first meeting begins.
- Screenshot of the raw data table output from Cell 2 — showing all five rows including the NULL values and inconsistent capitalisation
- Screenshot of the cleaned data table from Cell 4 — showing three rows with uppercase regions and no NULL values
- Screenshot of the final sales summary from Cell 6 — showing total sales grouped by region
- A short paragraph (4–6 sentences) explaining the pipeline flow: what problem it solves, what each stage does, and what the output enables
- A short paragraph (3–5 sentences) explaining the specific roles of Databricks and AWS Lambda — what each one does and why the separation of responsibilities matters
A strong explanation does three things: it names the business problem, traces the solution step by step, and connects the output to a real use. Here is the structure to follow:
Problem: A company receives a weekly sales file that contains missing values and inconsistent formatting, making it unsuitable for direct reporting. Process: The file is uploaded to Amazon S3, which triggers Lambda to start the Databricks notebook automatically. The notebook reads the raw data, removes rows with missing sales figures, standardizes region names to uppercase, and saves the cleaned result as a permanent Delta table. Output: The final table is immediately available for dashboards and queries — a regional sales summary can be produced in seconds from data that arrived messy and unprocessed minutes before.
Databricks is the processing engine: it reads the raw file, applies the cleaning and transformation logic, and writes the output table. All the analytical work — SQL queries, data validation, aggregation — happens inside Databricks. AWS Lambda is the activation mechanism: it detects the S3 upload event and starts the Databricks workflow automatically. Lambda does not touch the data itself; its sole job is to notice that something happened and tell Databricks to respond. This separation means each tool does what it is designed for — Lambda handles event-driven activation at cloud scale, while Databricks handles data processing at analytical scale.
Knowledge Check
Five final questions drawing on the complete capstone. Select the best answer for each.
1. In the capstone, why are Bob and Ethan’s rows removed during cleaning but not Alice, Charlie, or Diana’s?
2. The WEST total in Cell 6 is 1,150. How is that figure calculated?
3. What is the difference between the cleaned_sales view created in Cell 3 and the final_sales_report table created in Cell 5?
4. In Cell 7, Step 2 says “AWS Lambda trigger activated.” What real event does this represent in a live pipeline?
5. Why is it important to view the raw data in Cell 2 before running the cleaning query in Cell 3?