What you will be able to do
- Explain how a streaming table processes each input row once and why its existing rows stay as they are when the query or a joined dimension changes
- Explain how a materialized view stays correct by choosing between an incremental refresh and a full recompute, and what each one costs
- Choose a streaming table or a materialized view for a dataset based on how mutable its source is, the latency it needs, the cost of a full recompute and how often it refreshes
Key concept
Process once vs. always correct — A streaming table reads each new source row once, appends the result and never goes back to it, which makes it cheap and fast. A materialized view always returns the same result as running its query as a batch over the current source data, and it pays to recompute whatever is needed to stay correct.
1.Streaming tables: each row once, never revisited
A Lakeflow pipeline can write its results to two kinds of dataset: streaming tables and materialized views. Choose the wrong one and you get one of two problems. A dashboard quietly shows numbers built from outdated data, or a pipeline recomputes months of history every time it runs. Both kinds are Delta tables that one pipeline defines and keeps up to date. The difference is how each one treats data it has already processed.
A streaming table is a Delta table that processes each input row exactly once. On each update, its flows read only the new data from a streaming source and append the results. That fits ingestion, where data keeps arriving and you need to capture every record without reprocessing the ones you already have. Supported sources include cloud object storage through Auto Loader and message buses such as Apache Kafka, Azure Event Hubs and Google Pub/Sub. The Auto Loader setup is covered in building streaming pipelines with Auto Loader. In SQL, you read the source with the STREAM keyword, and a standalone streaming table can carry its own refresh schedule.
CREATE OR REFRESH STREAMING TABLE sales
SCHEDULE EVERY 1 hour
AS SELECT * FROM STREAM read_files(
"/Volumes/my_catalog/my_schema/my_volume/path/to/data",
format => "json"
);Checkpoints are what make the process-once guarantee work. A streaming table uses checkpoint management to remember how far each flow has read. Each refresh then picks up only the records that arrived since the last update, which is why streaming tables suit low-latency work and large volumes of append-only data. If you turned the checkpoints off, the table would lose that guarantee rather than gain anything. For the lowest latency, a pipeline can run in real-time mode, which delivers sub-second end-to-end latency.
Because rows are never revisited, a streaming table does not recompute when something upstream changes. If you edit the query, only rows processed after the edit follow the new logic. You need to keep track of every earlier version of the query that has run on the table. Joins behave the same way. When a streaming table joins a stream to a dimension table and a dimension row later changes, the rows that were already written keep the old dimension values. That can be acceptable when you want results fast and can tolerate some being wrong. It is not acceptable when the result must always be correct.
A full refresh is how you bring old rows up to date. It truncates the table, clears the flow checkpoints and reprocesses every record from the source. If the source has already discarded data, those records are lost. A Kafka topic past its retention window is the usual example. A second option, resetting the streaming flow checkpoints, reprocesses the source through the selected flows but keeps the data already in the table.
Streaming tables also expect bounded state. The stream must either end naturally, like a fixed directory of files, or be bounded by a watermark. A watermark tells the engine how long to wait for late events before it treats a time window as complete. An unbounded stream without a watermark can make the pipeline fail from memory pressure. A watermark limits how much state the stream keeps. It does not let an append-only table absorb updates or deletes from a changing table. How watermarks work is covered in watermarks and stateful streaming. When the source itself updates or deletes rows, the tool is AUTO CDC, which applies those changes to a streaming table instead of appending them. See AUTO CDC and SCD types.
Checkpoint 1 of 7· Fill the gap
This standalone streaming table ingests JSON files with Auto Loader. Which keyword makes the query read its source with streaming semantics, so each file is processed only once?
CREATE OR REFRESH STREAMING TABLE sales
SCHEDULE EVERY 1 hour
AS SELECT * FROM ? read_files(
"/Volumes/my_catalog/my_schema/my_volume/path/to/data",
format => "json"
);A streaming table's query has to be a streaming query, and in SQL the STREAM keyword applies streaming semantics to the source. Each refresh then reads only the files that arrived since the last update.
Source: docs.databricks.comCheckpoint 2 of 7· Check yourself
A streaming table joins an orders stream to a customers dimension table. After many orders are written, a customer's region changes in the dimension table. What does the next default refresh do to the orders already in the streaming table?
A streaming table never goes back to rows it has already appended, so its joins do not recompute when a dimension row changes. If the result must always reflect the current dimension, you need a materialized view or a full refresh.
“Joins in streaming tables do not recompute when dimensions change.”Source: docs.databricks.com
2.Materialized views: precomputed results that stay correct
A materialized view stores the result of a query and keeps it in step with its sources. A standard view runs its query every time someone reads it. A materialized view caches the result and refreshes it on a schedule or when the pipeline is triggered, so reads are fast. You write an ordinary batch query with joins, aggregates and filters. Databricks tracks changes in the upstream data and decides how to bring the stored result up to date.
CREATE OR REPLACE MATERIALIZED VIEW regional_sales
AS SELECT *
FROM partners
INNER JOIN sales USING (partner_id);Correctness is the guarantee. A refreshed materialized view gives the same result as running its query as a batch over all current source data. That holds for late data, out-of-order data, and updates and deletes in any input. If a row in partners changes, the joined result changes with it. This is exactly what a streaming table join does not do.
How much a refresh costs depends on how much Databricks has to recompute. A default refresh tries an incremental refresh first, which finds what changed since the last update and merges only the affected results. In one example, 200 new customers in three countries and their transactions arrive. An incremental refresh of a sales report grouped by country rewrites three rows instead of the whole report. Databricks runs a cost analysis and uses either the incremental refresh or a full recompute, whichever is cheaper. Both produce the same output. You can set a refresh policy that makes the refresh fail instead of falling back to a full recompute.
| Update type | Materialized view | Streaming table |
|---|---|---|
| Refresh (default) | Updates results to match the current output of the query. Incremental when that is cheaper. | Processes only new records and appends them, using the current definition |
| Full refresh | Recomputes the whole result. The data is identical to a default refresh. | Truncates the table, clears flow checkpoints and reprocesses every source record |
| Reset streaming flow checkpoints | Not applicable | Clears checkpoints and reprocesses the source, keeping existing table data |
Being correct has costs. Some changes to the inputs force a full recompute, which can be expensive, and some computations can't be done incrementally at all. Materialized views are also not built for low latency: a refresh takes seconds or minutes, not milliseconds. Finally, if a UDF called by the view changes behaviour in a way Databricks doesn't detect, such as after a library upgrade, you have to run the full refresh yourself.
Checkpoint 3 of 7· Check yourself
Your team's Lakeflow pipeline runs on classic compute. It defines a materialized view that sums a very large transactions table by country, and each day only a few thousand new rows arrive. What does each default refresh of this view do?
Incremental refresh needs serverless compute. On a classic-compute pipeline, every refresh of a materialized view is a full recompute, however well the query would support incremental refresh. The view still refreshes and stays correct, but each refresh costs a full recompute.
“Only materialized views updated using serverless pipelines can use incremental refresh. Materialized views that do not use serverless pipelines are always fully recomputed.”Source: docs.databricks.com
Checkpoint 4 of 7· Exam question
A daily_region_revenue dataset aggregates SUM(order_amount) by region and joins against a customers dimension table that receives updates and deletes throughout the day. Business analysts query this dataset directly for dashboards and expect the aggregate to reflect the latest state of customers, but do not need sub-second freshness. Which approach correctly defines this dataset in Lakeflow Spark Declarative Pipelines?
CREATE OR REFRESH ??? daily_region_revenue AS
SELECT c.region, SUM(o.order_amount) AS total_revenue
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
GROUP BY c.region;
Correct answer: B — MATERIALIZED VIEW, because it recomputes the aggregation as needed against the current state of both orders and customers, correctly reflecting the updates and deletes.
- A. Streaming tables assume an append-only source and process each record exactly once; they are not designed to automatically re-derive prior aggregate rows when an upstream dimension table changes, so updates to
customerswould not be reflected correctly. - B. This is correct because results are recomputed as needed to reflect the current state of source data, which is exactly what is required when a join input like
customersreceives updates and deletes that must be reflected in the aggregate. - C. Schema evolution controls how a pipeline reacts to changes in the structure of incoming data, such as new columns, not how it reacts to row-level updates or deletes in a joined table, so this option describes the wrong mechanism entirely.
- D. Watermarks bound how long Structured Streaming waits for late-arriving event-time data in stateful aggregations; they do not enable a streaming table to absorb update and delete operations from a changing dimension table.
3.Choosing between a streaming table and a materialized view
Start from the source: is it append-only, or do rows change? If new rows only ever arrive, as with files from Auto Loader, Kafka events or clickstream logs, a streaming table processes each one once, with low latency and low cost per update. If the result depends on rows that are updated or deleted, or on joins and aggregates over the full current state of several tables, choose a materialized view. Only it recomputes so the output reflects that state.
| Requirement | Streaming table | Materialized view |
|---|---|---|
| Source shape | Append-only. Each record processed once. | Joins and aggregates over data that is updated or deleted |
| Correctness after upstream changes | Existing rows are not recomputed | Always matches a batch run of the query |
| Latency | Low, down to sub-second in real-time mode | Seconds or minutes per refresh |
| Cost of refresh | Only new records | Incremental where possible, otherwise a full recompute |
| Source keeps no history (Kafka) or old data is deleted | Correct choice | Avoid: a full refresh would lose records |
Cost points the same way from both directions. A materialized view's sources must be able to handle a full refresh, because one can always happen. When a full recompute would cost too much, for example over a very large table, use a streaming table to get exactly-once processing. Never define a materialized view over a source whose records must be processed only once. That includes Kafka topics that don't keep history, Auto Loader ingestion, and tables where you delete or archive old partitions but still need their information downstream. A full refresh over such a source would reflect only what is left in it.
When many consumers read the same result, that favors a materialized view. Dashboards, reports and several teams running the same expensive join or aggregate each pay its cost on every query against a standard view. A materialized view computes the result once per refresh and serves the stored copy, which lowers both query latency and compute. Designing dimensional models around this is covered in materialized views for dimensional models.
The medallion architecture puts these rules into practice. Bronze ingestion is mostly stateless appends of large volumes, so it suits streaming tables. Silver transformations involve joins, aggregations and deduplication. They default to materialized views with incremental refresh, and use streaming only where speed matters much more than accurate results. Gold aggregations are usually smaller and stateful, and belong in materialized views.
How often a dataset refreshes is a separate setting from which type it is. Pipeline mode doesn't change the dataset type: streaming tables and materialized views both run in triggered or continuous mode. Triggered mode processes the data available at the start of the update and then stops. It suits refreshes every 10 minutes, hourly or daily, and is cheaper because compute runs only for the update. Continuous mode suits freshness between about 10 seconds and a few minutes, but it needs an always-running cluster. Standalone streaming tables and materialized views always refresh in triggered mode. Running a materialized view continuously does not turn it into a low-latency table, and a schedule does not make a streaming table recompute its old rows.
Checkpoint 5 of 7· Match them up
A team is designing a Lakeflow pipeline and has four requirements. Match each requirement to the dataset type or pipeline mode that meets it.
Tap a term, then the definition that fits it.
Which dataset type to use depends on the source and on how correct the result must be. A Kafka topic must be processed only once, so it needs a streaming table, and results over changing rows need a materialized view. How fresh the data must be is a separate decision that you make with the pipeline mode, triggered or continuous, and either dataset type can run in either mode.
“Do not define a materialized view against a data source if records should only be processed once. Instead, use streaming tables.”Source: docs.databricks.com
Checkpoint 6 of 7· Exam question
A Lakeflow Spark Declarative Pipelines pipeline uses Auto Loader (cloudFiles) to land append-only clickstream JSON files. Downstream consumers need every event processed exactly once, with the lowest possible latency and compute cost per micro-batch. Which table type should the engineer define for this dataset?
from pyspark import pipelines as dp
@dp.table
def clicks_raw():
return (spark.readStream
.format("cloudFiles")
.option("cloudFiles.format", "json")
.load("/Volumes/raw/clickstream/"))
Correct answer: B — A streaming table, because it processes each newly arrived record exactly once through incremental append-mode computation, matching the append-only source at low latency and cost.
- A. Materialized views recompute results as needed against the current state of the source, which is useful for changing or joined data but wastes compute reprocessing an append-only stream that never needs a full recalculation.
- B. A streaming table is the correct choice here because it maintains a streaming flow over an append-only source, so Lakeflow processes only the newly arrived clickstream files each micro-batch instead of recomputing history, which minimizes both latency and compute cost.
- C. Checkpoints are what let a streaming table track which records it already processed exactly once; disabling them would break incremental processing and force reprocessing, which is the opposite of the low-cost goal.
- D. Materialized views do not use continuous refresh to force full historical joins for ordering; continuous mode only controls how often the pipeline checks for new data, and this description misrepresents how materialized views compute results.
Checkpoint 7 of 7· Exam question
Which of the following are valid, technically accurate reasons for a data engineer to choose a materialized view instead of a streaming table for a given dataset in a Lakeflow Spark Declarative Pipelines pipeline? (Select 3)(Select 3)
Correct answers: A, B, E — Several downstream teams query the same aggregated dataset repeatedly, so precomputing and caching the result once avoids every consumer recomputing the same joins and aggregations.; The upstream source table receives in-place updates and deletes, and the dataset must reflect the current state of that source rather than only newly appended rows.; The dataset definition performs a multi-way join and a GROUP BY aggregation whose correctness depends on seeing the full current state of every input table.
- A. This is a valid reason: materialized views cache a precomputed result, so when many consumers repeatedly query the same aggregation, computing it once and serving it from storage is cheaper than every consumer re-deriving it.
- B. This is a valid reason: results are recomputed against the current state of the data, so an option like this correctly reflects in-place updates and deletes on the source in a way an append-only streaming table cannot.
- C. This is not a defining reason; exactly-once semantics is a property of streaming tables processing append-only data, and wanting to inspect results during development is not the technical driver behind the latency, cost, or refresh tradeoff.
- D. This describes the opposite scenario: a continuously growing append-only stream needing the lowest per-record latency is the textbook case for a streaming table, not this alternative.
- E. This is a valid reason: joins and aggregations whose correctness depends on the complete, current state of every input table are exactly the workloads this alternative is designed to recompute correctly.
- F. Schema inference timing is a property of Auto Loader configuration on the ingestion source, not a reason tied to choosing between the two table types for latency, cost, or refresh requirements.
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Each input row is handled only once, which models the vast majority of ingestion workloads”
↩︎ Streaming tables: each row once, never revisited“Streaming tables use checkpoint management, which makes them well-suited for low-latency streaming.”
↩︎ Streaming tables: each row once, never revisited“An unbounded stream that does not have a watermark can cause a pipeline to fail due to memory pressure.”
↩︎ Streaming tables: each row once, never revisited“To stream source data that changes over time (for example, records that are updated or deleted at the source), use AUTO CDC”
↩︎ Streaming tables: each row once, never revisited“Materialized views are always correct because they automatically recompute joins when dimensions change.”
↩︎ Materialized views: precomputed results that stay correct“Joins in streaming tables do not recompute when dimensions change.”
↩︎ Exam trap 1“A row that has already been appended to a streaming table will not be re-queried with later updates to the pipeline.”
↩︎ Prediction“Joins in streaming tables do not recompute when dimensions change.”
↩︎ Checkpoint - 2.
“A full refresh of a streaming table can drop records if the source no longer retains the original data”
↩︎ Streaming tables: each row once, never revisited“a default refresh of a streaming table trades data correctness for lower time and resource costs.”
↩︎ Key concept“On classic compute, a materialized view is always fully recomputed.”
↩︎ Exam trap 2 - 3.
“Unlike standard views, which recompute results on every query, materialized views cache the results and refresh them on a specified interval.”
↩︎ Materialized views: precomputed results that stay correct“The latency of updating a materialized view is in the seconds or minutes, not milliseconds.”
↩︎ Materialized views: precomputed results that stay correct - 4.
“Databricks runs a cost analysis to choose the cheaper option between an incremental refresh and a full recompute.”
↩︎ Materialized views: precomputed results that stay correct“For queries where a full refresh would be cost-prohibitive, use streaming tables to guarantee exactly-once processing.”
↩︎ Choosing between a streaming table and a materialized view“Do not define a materialized view against a data source if records should only be processed once.”
↩︎ Exam trap 3“Only materialized views updated using serverless pipelines can use incremental refresh. Materialized views that do not use serverless pipelines are always fully recomputed.”
↩︎ Checkpoint“Do not define a materialized view against a data source if records should only be processed once. Instead, use streaming tables.”
↩︎ Checkpoint - 5.
“By precomputing expensive or frequently used queries, Materialized views lower query latency and resource consumption.”
↩︎ Choosing between a streaming table and a materialized view - 6.
“Use batch processing (with incremental refresh in materialized views).”
↩︎ Choosing between a streaming table and a materialized view - 7.
“Continuous pipelines require an always-running cluster, which is more expensive but reduces processing latency.”
↩︎ Choosing between a streaming table and a materialized view“Pipeline mode is independent of the type of table being computed.”
↩︎ Exam trap 4