Glossary · Pipelines and tooling
What is backfill?
A backfill reruns a pipeline for past periods: to fill a gap after an outage, to load history for a new table, or to apply changed logic to old data. Done well it is idempotent and partition by partition; done badly it duplicates rows and scans all of history at once.
When you need a backfill
- Gaps: a source or pipeline failed for some days and the table has holes.
- New tables: a new model or metric needs its history, not only data from today.
- Logic changes: a bug fix or a new definition must apply to past data too.
- Late data: records arrived after their period was processed.
Backfills on BigQuery
The safe pattern is to replace whole periods, so a rerun overwrites instead of appending. A multi-statement transaction deletes and rebuilds a date range atomically:
DECLARE start_date DATE DEFAULT '2026-10-01';
DECLARE end_date DATE DEFAULT '2026-10-31';
BEGIN TRANSACTION;
DELETE FROM `my-project.marts.daily_revenue`
WHERE order_date BETWEEN start_date AND end_date;
INSERT INTO `my-project.marts.daily_revenue` (order_date, country, revenue)
SELECT DATE(created_at), country, SUM(amount)
FROM `my-project.sales.orders`
WHERE created_at >= TIMESTAMP(start_date)
AND created_at < TIMESTAMP(DATE_ADD(end_date, INTERVAL 1 DAY))
GROUP BY 1, 2;
COMMIT TRANSACTION;
Running it twice leaves the same rows. The filter on created_at itself, rather than on DATE(created_at), keeps partition pruning reliable on a table partitioned by that timestamp. Alternatives are partition overwrite (dbt insert_overwrite, or a query job writing to a partition decorator such as daily_revenue$20261001 with WRITE_TRUNCATE) and MERGE on a key.
Cost and quota notes
- Size the batches. One statement over a month scans each source partition once. Thirty daily runs that each scan all history scan it thirty times. Check bytes with a dry run, and price it with BigQuery pricing or the pricing calculator.
- Partition modification quotas. Rewriting many partitions with many jobs can hit partition modification limits; fewer, larger jobs help.
- Concurrent DML. Parallel backfill runs against one table queue up and can fail with too many DML statements outstanding.
- Isolate the compute. On editions, run large backfills in their own reservation, or at batch priority, so they don't slow production pipelines.
Common pitfalls
- Non-idempotent steps. Plain
INSERTappends duplicates on every rerun; see idempotent pipeline. CURRENT_DATE()in transformations. The backfill computes today's answer for every past day.- Forgetting downstream. Rebuilding a table doesn't rebuild what reads from it; follow the DAG and backfill dependents in order.
- Airflow catchup surprises. Unpausing a DAG with
catchup=Trueand an oldstart_datetriggers an unplanned backfill of every missed interval.
FAQ
How do I backfill in Airflow?
Airflow 3 runs backfills in the scheduler, started from the UI or the API for a date range. Airflow 2 uses the airflow dags backfill command. Either way, each run gets its own logical date, so tasks must use it instead of the current date.
How do I backfill a dbt incremental model?
Run it with --full-refresh to rebuild everything, or pass a date range through variables that the is_incremental() filter uses. Models with the microbatch strategy accept --event-time-start and --event-time-end to reprocess a window batch by batch.
How much does a backfill cost on BigQuery?
Roughly what the normal runs for that period would cost, plus overhead if you rebuild more than needed. On on-demand pricing, a backfill that scans each partition once costs far less than one that scans all history for every day. Estimate with a dry run first.
