Sub topic 9
Running updates: triggered, continuous and full refresh
This chapter covers how a pipeline runs once you have defined its datasets. It assumes you can read the SQL and Python examples from earlier chapters. You should also know the difference between batch and streaming reads, and what a Unity Catalog schema is.
What an update is
An update is one run of a pipeline. Databricks reads your source files, builds the dependency graph, and processes each dataset in the right order. You never schedule individual tables. You choose how the whole pipeline runs.
There are two pipeline modes and one special kind of update:
- Triggered mode processes available data, then stops.
- Continuous mode keeps running and processes data as it arrives.
- A full refresh reprocesses a dataset from scratch.
Triggered mode
A triggered pipeline starts, updates every dataset with the data available at that moment, and then shuts down compute. You start it manually, with an API call, or from a Lakeflow Job on a schedule.
This mode suits most batch and hourly workloads. You pay only while the update runs. Latency is as high as your schedule interval.
In a bundle, triggered mode is the setting continuous: false, as in the deployment example shown later in this tutorial.
Continuous mode
A continuous pipeline starts an update and keeps it running. New files or records flow through the graph within seconds or minutes. If the update fails, the pipeline restarts it.
Use it when freshness matters more than cost. The compute stays on all the time, so it costs more than a triggered pipeline that runs a few times a day.
resources:
pipelines:
orders_pipeline:
name: orders_pipeline
catalog: main
schema: demo
serverless: true
continuous: true
libraries:
- file:
path: ../src/orders.sqlChanging continuous from false to true is the only difference from a triggered setup.
Choosing a mode
| Question | Triggered | Continuous |
|---|---|---|
| Data freshness needed | Minutes to hours | Seconds to minutes |
| Compute runs | Only during the update | Always |
| Typical cost | Lower | Higher |
| Started by | Schedule, API or user | The pipeline itself |
Full refresh
A normal update is incremental. A streaming table only reads data it has not seen before, using its checkpoint. That is efficient, but it means the table will not pick up changes to old input data or to your transformation logic.
A full refresh clears the table and reprocesses everything from the source. Use it when you:
- change the logic of a streaming table and want old rows recomputed,
- fix a bug that wrote bad data,
- need to reload after the source data was corrected.
You can run a full refresh on the whole pipeline or select only some tables. Refreshing only the affected tables saves time and cost. Downstream datasets are recomputed from the refreshed tables.
If a streaming table must never be reset by accident, set the table property pipelines.reset.allowed to false. A full refresh then skips that table.
CREATE OR REFRESH STREAMING TABLE orders_bronze
TBLPROPERTIES ("pipelines.reset.allowed" = "false")
AS SELECT *
FROM STREAM read_files(
'/Volumes/main/demo/raw/orders/',
format => 'json'
);Common errors
- Expecting a code change to rewrite old rows. A normal update applies new logic only to new data. Run a full refresh to recompute history.
- Running continuous mode for a daily job. The compute runs all day for one load.
- Running a full refresh on a table whose source data has expired.
- Forgetting that a full refresh on a bronze table also recomputes everything downstream of it.
Exercise
Your team changes the cast on the amount column in orders_silver. The bronze files are still in the volume. Old silver rows have the old type handling. Which update do you run, and on which tables, to fix this at the lowest cost?
Show answer
Run a full refresh on orders_silver only, not on the whole pipeline. Bronze does not need reprocessing. The silver table is rebuilt from the existing bronze data, and daily_revenue is then recomputed from the new silver rows.
Exercise
A dashboard must show new orders within one minute of arrival. Which pipeline mode do you pick, and what is the main cost?
Show answer
Continuous mode. The compute stays on all the time, so the cost is higher than for a triggered pipeline that runs on a schedule.