Why your Dataform incremental table keeps adding duplicates
Your Dataform incremental table keeps adding duplicates? A NULL in the merge key could be why. Here’s how it happens with GA4 and how to stop it.
Elisa Liu3 Nov 2026
Blog
Prasanna Venkatesan7 February 20253 min read
Efficient data loading is crucial for managing and updating tables in Dataform. Various strategies exist to handle different use cases, including truncate and load, appending data, and leveraging incremental tables with unique keys. This blog explores these primary methods and more:
In this method, all existing records in the target table are deleted and replaced with a fresh table. This approach works well when a full table refresh is necessary or if managing slowly changing data.
config {
type: "table"
}
SELECT
id,
name,
timestamp
FROM
${ref("source_table")}
By defining the table type as table, Dataform ensures that each run recreates the table, effectively performing a truncate and load operation.
This method appends new data to an existing table while preserving historical records. It is ideal for use cases where past data must remain unchanged, and only new records are added.
config {
type: "incremental"
}
SELECT
id,
name,
timestamp
FROM
${ref("source_table")}
WHERE
timestamp = CURRENT_DATE() - 2This ensures that only records from two days ago, based on CURRENT_DATE() - 2, are appended to the target table.
This method ensures that only one row per unique key is retained and updates existing records if changes occur. This is useful for deduplicating or updating records efficiently.
config {
type: "incremental",
uniqueKey: "id"
}
SELECT
id,
name,
position,
timestamp
FROM
${ref("source_table")}
WHERE
timestamp = CURRENT_DATE() - 2Dataform automatically handles the merge process—if a record with the same id already exists, it gets updated. If a new id appears, it is inserted as a new row.
This method ensures that before inserting new data incrementally, the system deletes records from the last two days to accommodate any late-arriving updates. This is useful for ensuring data freshness while still maintaining an incremental approach.
config {
type: "incremental"
}
pre_operations {
DELETE
FROM
${self()}
WHERE
timestamp >= CURRENT_DATE() - 2;
}
SELECT
id,
name,
position,
timestamp
FROM
${ref("source_table")}
WHERE
timestamp >= CURRENT_DATE() - 2
This ensures that any late-arriving updates from the last two days are reflected correctly while keeping the rest of the data intact.
| Method | Best Use Case |
| Truncate and Load | When a full table refresh is needed. |
| Append or Insert-Only | When historical records must be preserved. |
| Incremental Load with Unique Keys | When deduplication and updates are required. |
| Incremental Load with Rolling Delete | When handling late-arriving updates for the last n number of days. |
Understanding these approaches in Dataform allows you to optimise your ETL/ELT workflows and effectively manage data changes for various use cases in BigQuery and other Data Warehouses.
Have you used any of these methods in Dataform? Reach out to let us know, and contact us if we can help you with anything Dataform/BigQuery related! 🚀
We build and review Dataform pipelines in BigQuery: tested models, assertions and documentation your team can maintain.
Bring data to connect, a question to investigate or something to fix or build. We can agree a focused scope directly.
Your Dataform incremental table keeps adding duplicates? A NULL in the merge key could be why. Here’s how it happens with GA4 and how to stop it.
Elisa Liu3 Nov 2026
TimesFM spots unusual days in BigQuery; ARIMA_PLUS explains why. We tested both on a year of GA360 data to turn traffic drops into clear answers.
Elisa Liu3 Nov 2026
A year ago, I wrote about getting a BigQuery warehouse ready for AI ( Easy ways to prepare your BigQuery warehouse for AI) , but didn't look properly into Knowledge Catalog (known as Dataplex at the time). We decided to go back and look through Google's Knowledge Catalog properly: what's actually in there, how it works and what it relates to. What Knowledge Catalog is Knowledge Catalog is Google's metadata layer for BigQuery data (and a few other sources). It sits alongside your tables rather
Katie Kaczmarek15 Sept 2026