Unit 12 Cloud Pipelines Notes

Unit 12 — Capstone: End-to-End Pipeline | DataSoSi
Cloud Data Pipelines · Unit 12 of 12 · Capstone

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.

This is the unit where everything you have learned stops being a collection of separate skills and becomes one coherent system. You will take a raw, messy sales dataset all the way through to a clean regional summary table — the same journey a real business pipeline makes, every day, without anyone pressing a button.
4 Sections
7 Notebook Cells
Full Pipeline — All Units Applied
1234 5678 9101112

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
Four sections. Select individually or expand all.
📊
Business Scenario
Weekly Sales File Processing
A company receives a weekly sales file containing employee names, sales figures, and regional data. The file must be received, validated, cleaned, transformed, saved as an output table, and made available for the weekly business report — all without manual intervention once the file arrives.
The Complete Pipeline Flow
CSV
Raw sales file uploaded to S3 raw/ folder
Unit 3 — Amazon S3 as a Data Inbox
↓
λ
Lambda detects the upload and triggers the notebook
Units 8–9 — Automation Basics and Lambda
↓
READ
Databricks reads and inspects the raw data
Units 4–5 — First Notebook and Reading Data
↓
CLN
SQL cleans — removes nulls, standardizes text
Unit 6 — Cleaning and Transforming Data
↓
OUT
Cleaned data saved to final_sales_report Delta table
Unit 7 — Writing Outputs
↓
RPT
Business summary query — total sales by region
Unit 7 — GROUP BY and SUM
Every Unit, One Purpose
Units 1–2
What a pipeline is and why it exists
Unit 3
S3 — where files land
Units 4–5
Notebooks — reading and inspecting data
Unit 6
SQL — cleaning and transforming
Unit 7
Delta tables — saving output
Units 8–9
Lambda — automation trigger
Unit 10
Execution modes — full automation
Unit 11
Monitoring — logs and retries

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.

Cell 1 — Create the Raw Dataset
PythonCell 1 — Raw Data with Real Problems
raw_data = [
    [“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”)
What Is Happening Here

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.

Cell 2 — View the Raw Data
SQLCell 2 — Inspect Before Cleaning
SELECT * FROM raw_sales;
Expected Output
employeesalesregion
Alice500west
BobNULLeast
Charlie700north
Diana650west
EthanNULLsouth
What Is Happening Here

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.

Cell 3 — Clean the Data
SQLCell 3 — Remove Nulls and Standardize
CREATE OR REPLACE TEMP VIEW cleaned_sales AS
SELECT employee, sales, UPPER(region) AS region
FROM raw_sales
WHERE sales IS NOT NULL;
What Is Happening Here

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.

Cell 4 — Confirm the Cleaned Data
SQLCell 4 — Verify Cleaning Result
SELECT * FROM cleaned_sales;
Expected Output
employeesalesregion
Alice500WEST
Charlie700NORTH
Diana650WEST
What Is Happening Here

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.

Cell 5 — Save the Final Output Table
SQLCell 5 — Permanent Delta Table
CREATE OR REPLACE TABLE final_sales_report AS
SELECT * FROM cleaned_sales;
What Is Happening Here

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.

Cell 6 — Business Summary Report
SQLCell 6 — Regional Sales Totals
SELECT region, SUM(sales) AS total_sales
FROM final_sales_report
GROUP BY region;
Expected Output
regiontotal_sales
WEST1150
NORTH700
What Is Happening Here

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.

Cell 7 — Simulate the Full Automated Pipeline
PythonCell 7 — End-to-End Simulation
print(“Step 1: Sales file uploaded to S3”)
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”)
Expected Output
Step 1: Sales file uploaded to S3 Step 2: AWS Lambda trigger activated Step 3: Databricks notebook started Step 4: Raw data cleaned Step 5: Final output table created Step 6: Business report ready
What Is Happening Here — The Complete Picture

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.

Capstone Submission Checklist
  • 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
Writing Your Pipeline Flow Explanation

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:

Explanation Structure

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.

Writing Your Roles Explanation
Role Explanation Structure

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?

Course Complete
Cloud Data Pipelines with Databricks & AWS
You have built a complete, automated cloud data pipeline from first principles — without heavy coding and without losing sight of the business problems it solves.
Storage
Amazon S3 — the cloud data inbox
Processing
Databricks — reading, cleaning, transforming
Automation
AWS Lambda — event-driven triggering
Output
Delta tables — reliable, reusable results
Operations
Monitoring, logs, retries
SQL
SELECT, WHERE, UPPER, GROUP BY, SUM