Unit 7 Cloud Pipelines Notes

Unit 7 — Writing Outputs: Tables and Delta | DataSoSi
Cloud Data Pipelines · Unit 7 of 12 · Output Storage

Writing Outputs: Tables and Delta

Learn how to save cleaned data as a reusable table — and understand why stored outputs are what dashboards, reports, and business decisions actually depend on.

A chef spends hours preparing a perfect dish. But if there is no plate to serve it on, it cannot reach the table. In data pipelines, cleaning the data is the preparation — saving it to an output table is the plate. Without that final storage step, the work disappears the moment the notebook session ends, and nobody else can benefit from it.
4 Sections
5 Hands-On Cells
SQL — No Advanced Knowledge Needed
123456 7 89101112

Learning Objectives

  • Explain why businesses save cleaned data and what happens if they do not
  • Describe what an output table is and what makes a Delta table different from a regular table
  • Create a cleaned dataset, register it as a SQL view, and save it as a permanent output table
  • Read back from a saved table and run a business aggregation query using GROUP BY and SUM
  • Explain how the output table created in this unit connects downstream to dashboards and reporting tools
Four sections. Select individually or expand all.

Every unit so far has produced data that only existed inside an active notebook session. The moment the session ends, that data is gone. A temporary SQL view — like the ones you created in Unit 6 — lives only as long as the notebook is running. If someone opens the Databricks workspace tomorrow and tries to query sales_table, they will find nothing. Output tables change this permanently.

Everyday Analogy — The Shared Google Doc

Imagine writing a detailed report in a word processor and never saving it. It looks perfect on your screen — until the power cuts out and everything disappears. Saving to a shared drive is the difference between work that only you can see, temporarily, and work that the whole team can access, reliably, any time they need it. Saving cleaned data to an output table is exactly this: making the result of the pipeline’s work permanently available to every tool and person downstream.

What Goes Wrong Without Stored Output
Dashboards Cannot Refresh
A Power BI or Tableau dashboard reads from a named table. If the pipeline cleans data but never writes it to a permanent table, the dashboard has nothing to connect to. It either shows stale data from the last successful run or shows nothing at all.
Work Cannot Be Reused
Without a stored output, every analyst who needs the cleaned data must rerun the entire cleaning pipeline themselves — reading the raw file, applying all the transformations, and hoping they produce the same result. A shared output table means the work is done once and reused by everyone.
No Audit Trail
A permanent table has a creation timestamp and a version history (in Delta format). A temporary view has neither. If questions arise about when data was processed or what it contained at a specific point in time, only the stored table can answer them.
What Is a Delta Table?

A Delta table is Databricks’ recommended format for storing output data. It is built on top of standard file storage but adds three capabilities that make it far more suitable for business pipelines than a plain CSV or temporary view.

FeatureWhat It Means in Plain Language
Reliable storageDelta tables are fault-tolerant — if a write fails halfway through, the table stays in its previous clean state rather than ending up half-written and corrupted.
Update supportYou can update or delete specific rows in a Delta table without rewriting the entire file — the same way you edit a cell in a spreadsheet without recreating the whole document.
Version historyEvery change to a Delta table is logged. You can query the table as it was at any previous point in time — essential for auditing and debugging.
Analytics performanceDelta tables are optimised for the kind of large-scale queries that dashboards and reports run — they return results much faster than reading raw files.
You Do Not Need to Understand Delta Deeply

In this course, you use Delta tables because they are the standard in Databricks and because they are reliable. You do not need to understand how they work internally. Think of them the way you think of a USB drive — you do not need to understand flash memory to save a file to one. The important thing is knowing when and why to use it.

Create a notebook named Unit7_Write_Output in Databricks, language Python, cluster attached. This notebook starts with already-cleaned data — the result of what Unit 6 produced. The goal now is to save that result permanently.

Cell 1 — Create the Cleaned Dataset
PythonCell 1 — Already-Cleaned Input
data = [
    [“Alice”, 500, “WEST”],
    [“Charlie”, 450, “NORTH”]
]

spark.createDataFrame(data, [“employee”, “sales”, “region”]) \
    .createOrReplaceTempView(“clean_sales”)
What Is Happening Here

This is the cleaned dataset — Bob’s row has already been removed and all region values are uppercase, exactly as Unit 6 produced. The two lines create a Spark DataFrame from the clean data and register it as a temporary SQL view named clean_sales. This view is the input to the storage step. Notice that no output appears for this cell — it is a setup step that prepares the data without displaying it.

Cell 2 — Confirm the View
SQLCell 2 — Preview Before Saving
SELECT * FROM clean_sales;
Expected Output
employeesalesregion
Alice500WEST
Charlie450NORTH
What Is Happening Here

Always preview before saving. This query confirms that the view contains exactly what you expect — two clean rows, correct column names, consistent formatting. It is a final check before writing to a permanent table. In a real pipeline, discovering an error here costs only seconds to fix. Discovering the same error after the table has been written, and dashboards have already read from it, costs far more.

Cell 3 — Save as a Permanent Output Table
SQLCell 3 — CREATE OR REPLACE TABLE
CREATE OR REPLACE TABLE final_sales_output AS
SELECT * FROM clean_sales;
What Is Happening Here

This is the most important cell in the unit. CREATE OR REPLACE TABLE creates a new, permanent Delta table named final_sales_output. The AS SELECT * FROM clean_sales part tells Databricks to populate it with everything from the clean view. The word REPLACE means that if a table with this name already exists — from a previous pipeline run, for example — it is overwritten with the fresh data. After this cell runs, final_sales_output exists in the Databricks Catalog as a real, persistent table. It survives after the notebook closes. Other notebooks, dashboards, and SQL tools can now query it by name at any time.

Cell 4 — Read Back from the Saved Table
SQLCell 4 — Verify the Stored Table
SELECT * FROM final_sales_output;
Expected Output
employeesalesregion
Alice500WEST
Charlie450NORTH
What Is Happening Here

This query reads from final_sales_output — the permanent table, not the temporary view. The result looks identical to Cell 2, but the source is fundamentally different. If you closed the notebook and reopened it tomorrow, this query would still return the same rows. The temporary view from Cell 1 would be gone, but the permanent table would remain. This distinction — temporary view vs. permanent table — is what separates a notebook session from a production pipeline output.

Cell 5 — Simulate a Business Report
SQLCell 5 — Regional Sales Aggregation
SELECT region, SUM(sales) AS total_sales
FROM final_sales_output
GROUP BY region;
Expected Output
regiontotal_sales
WEST500
NORTH450
What Is Happening Here

This query demonstrates exactly how a business uses a stored output table. SUM(sales) adds up all sales values. GROUP BY region tells SQL to calculate that sum separately for each region, so you get one total per region rather than one grand total. The label AS total_sales names the result column clearly for reporting. This is the kind of query a dashboard runs automatically every morning against final_sales_output to update a regional performance chart. The pipeline’s entire job — from S3 upload through cleaning to this table — exists to make this one query reliable and fast.

CSV
Raw file uploaded to S3
Unit 3
Done
↓
READ
Databricks reads and inspects
Unit 5
Done
↓
CLN
SQL cleans and transforms
Unit 6
Done
↓
OUT
Cleaned output saved to Delta table
This unit — final_sales_output becomes a permanent, queryable table in the Catalog
Now
↓
▶
Dashboards, reports, and analysts read the table
The downstream consumers — Power BI, Tableau, SQL queries, business reports
Downstream
The Output Table Is the Deliverable

Every step of the pipeline — the S3 bucket, the Lambda trigger, the cleaning logic — exists to produce one thing: a clean, reliable, reusable output table. That table is what the business actually uses. It is not an intermediate result; it is the finished product. When a manager opens a dashboard at 9 AM and sees accurate regional sales figures, they are reading from a table exactly like the one you just created.

Who Uses the Output Table
Dashboard Tools
Power BI, Tableau, and Looker connect directly to Delta tables in Databricks. Every time the dashboard refreshes, it runs a query against the latest version of the table. The pipeline feeds the dashboard — no manual exports, no file transfers.
Analysts and Data Teams
Instead of each analyst reprocessing the raw file independently, every team member queries the same shared output table. One source of truth, one cleaning process, no diverging results between people using different versions of the data.
Scheduled Reports
Automated reports — the weekly sales email, the monthly finance summary — run SQL queries against the output table on a schedule. As long as the pipeline keeps writing fresh data to the table, the reports update automatically.
Other Pipelines
One pipeline’s output often becomes another pipeline’s input. A cleaned sales table might feed a forecasting pipeline, a commission calculation job, or an inventory planning system — all reading from the same reliable source.

Cell 5 introduced two SQL tools that have not appeared before in this course. They are worth understanding clearly because they appear in almost every business report query.

Everyday Analogy — The Class Register Summary

A teacher has a register with 30 students, each belonging to one of four houses. To find out how many students are in each house, the teacher counts by group — all the Reds together, all the Blues together. That is GROUP BY: it collapses many rows into one row per group. SUM then adds up a number within each group. Together: “For each region, add up the sales figures of everyone in that region.” That is exactly what Cell 5 does.

KeywordWhat It DoesBusiness Use
SUM(column)Adds up all the values in a column. SUM(sales) totals every sales figure in the dataset into one number.Total revenue for the month. Total hours worked. Total units shipped.
GROUP BY columnDivides the rows into groups based on a column’s values, then applies the aggregation (SUM, COUNT, AVG) separately to each group.Sales by region. Orders by customer. Costs by department.
AS aliasGives the calculated result column a readable name in the output. SUM(sales) AS total_sales labels the column clearly.Makes reports and dashboards self-explanatory without extra documentation.
Why These Two Go Together

GROUP BY without an aggregation like SUM does nothing useful — you would just get one row per group with no calculation. SUM without GROUP BY gives you one grand total across the entire table. Together, they give you one calculated total per category — which is what nearly every business report in existence is trying to show.

Knowledge Check

Five questions covering Unit 7. Select the best answer for each question.

1. What is the key difference between a temporary SQL view and a permanent output table?

2. What does CREATE OR REPLACE TABLE final_sales_output AS SELECT * FROM clean_sales do?

3. In the aggregation query from Cell 5, what does GROUP BY region do?

4. Why should dashboards read from a stored output table rather than directly from the raw file?

5. A Delta table differs from a plain CSV in which important way?

Unit 7 Summary

What you covered in this unit

Output Tables

Permanent, queryable tables that store the cleaned results of a pipeline run — accessible to dashboards, analysts, and other pipelines at any time.

Delta Tables

Databricks’ recommended storage format. Supports updates, version history, and fault tolerance — making it far more reliable than plain CSV files for production use.

CREATE OR REPLACE TABLE

The SQL command that writes a permanent table. Each pipeline run can replace the previous version with fresh cleaned data using this single statement.

GROUP BY + SUM

Two SQL tools that work together to produce aggregated business reports — totalling or counting values per category, which is the foundation of most dashboards.

Output TableDelta TableCREATE OR REPLACE TABLETemporary ViewPermanent TableGROUP BYSUM()Databricks CatalogVersion History