# DBT Incremental insert\_overwrite static partitions

**URL:** <https://discourse.getdbt.com/t/dbt-incremental-insert-overwrite-static-partitions/8983>\
**Category:** Help\
**Tags:** bigquery, incremental\
**Created:** [July 4, 2023, 5:15pm UTC](https://discourse.getdbt.com/t/dbt-incremental-insert-overwrite-static-partitions/8983 "2023-07-04T17:15:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eli.sigal](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/eli.sigal/32/2603_2.png) [@eli.sigal](https://discourse.getdbt.com/u/eli.sigal)\
**Post date:** [July 4, 2023, 5:15pm UTC](https://discourse.getdbt.com/t/dbt-incremental-insert-overwrite-static-partitions/8983/1 "2023-07-04T17:15:51Z")

</div>

Hi.  
I am trying to figure out how to do dbt incremental with insert\_overwrite while using partitions\_to\_replace  
Please note - I am using GCP BQ.  
This is the config and partitions\_to\_replace

```auto
{% set partitions_to_replace = [
    'date_trunc(current_date, month)',
    'date_trunc(date_sub(current_date, interval 1 month), month)',
    'date_trunc(date_sub(current_date, interval 2 month), month)'

] %}

{{
    config(
        materialized='incremental',
        partition_by = { 'field': 'date', 'data_type': 'date',"granularity": "month" },
        cluster_by = ["field_a","field_b","field_c","field_d"],
        incremental_strategy = 'insert_overwrite',
        on_schema_change='sync_all_columns',
        partitions_to_replace=partitions_to_replace 
    )
}}

```

This is the if is\_incremental

```auto
select * from full_state_data
    {% if is_incremental() %}
    where month_start_date in ({{ partitions_to_replace | join(',') }})
    {% endif %}

```

I saw multiple discussions and threads about it and didn’t quite get it.  
When I run this - it will actually take MORE time and GIB to run this.  
I understand that the merge logic that is created behind the scenes defaults to False and that is why this is happening.  
The question is how to resolve this?  
Using the same logic with NO partitions\_to\_replace e.g.

```auto
{{
    config(
        materialized='incremental',
        partition_by = { 'field': 'date', 'data_type': 'date',"granularity": "month" },
        cluster_by = ["field_a","field_b","field_c","field_d"],
        incremental_strategy = 'insert_overwrite',
        on_schema_change='sync_all_columns'
    )
}}

select * from full_state_data
    {% if is_incremental() %}
    where month_start_date >= date_sub(_dbt_max_partition, interval 35 day)
    {% endif %}

```

Runs a bit more time than the original query though, it takes A lot less GIB

Any help to understand this would be appreciated
