# Dataform Incremental table - How to limit the table scan on the target table

**URL:** <https://discuss.google.dev/t/dataform-incremental-table-how-to-limit-the-table-scan-on-the-target-table/174793>\
**Category:** Data Analytics\
**Tags:** dataform, bigquery\
**Created:** [December 3, 2024, 10:37am UTC](https://discuss.google.dev/t/dataform-incremental-table-how-to-limit-the-table-scan-on-the-target-table/174793 "2024-12-03T10:37:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiovanniP](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/giovannip/32/3858_2.png) [@GiovanniP](https://discuss.google.dev/u/GiovanniP)\
**Post date:** [December 3, 2024, 10:37am UTC](https://discuss.google.dev/t/dataform-incremental-table-how-to-limit-the-table-scan-on-the-target-table/174793/1 "2024-12-03T10:37:24Z")

</div>

Hi All,

I’ve the following target: minimize the Mbytes used by Bigquery to load an incremental table.

This is the case:

Source table is a view which select only new added data from a source table:

```sql
create or replace SOURCE_VIEW
as
select *
from SOURCE_TABLE
WHERE ingestionTime >= maxIngestionTime

```

I’ve partitioned the target table on a date field which should be a good indicator if a record could be modified or not

```javascript
config {
    name : "whmovementTEST",
    schema : "ptestds1_bronze",
    type : "incremental",
    uniqueKey : ["key1", "key2"],
    bigquery: {
        partitionBy: "TIMESTAMP_TRUNC(compDate, MONTH)"
    }
}

```

I’d like that dataform generates in incremental mode a merge code like following:

```sql
MERGE into ${self()} AS target
USING (
select * 
from ${ref("SOURCE_VIEW")}
) as source
ON target.key1= source.key1
AND target.key2= source.key2
${when(incremental(),
    `AND target.comDate> (SELECT TIMESTAMP_ADD(MAX(compDate), -1, MONTH) FROM ${self()})`)}
}
WHEN MATCHED UPDATE ....
WHEN NOT MATCHED INSER ....

```

to scan only some of the partions on target table

How to customize the “ON” condition ? There could be an other way to reach the same purpose?

Thanks

---

<div class="post-metadata">

**Author:** ![olivier\_l](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/olivier_l/32/6384_2.png) [@olivier\_l](https://discuss.google.dev/u/olivier_l)\
**Post date:** [April 3, 2025, 10:15am UTC](https://discuss.google.dev/t/dataform-incremental-table-how-to-limit-the-table-scan-on-the-target-table/174793/2 "2025-04-03T10:15:23Z")

</div>

have you tried the [updatePartitionFilter](https://cloud.google.com/dataform/docs/create-tables#filter-rows-incremental-table) option in the config block ?
