# incremental model fails on second run

**URL:** <https://discourse.getdbt.com/t/incremental-model-fails-on-second-run/9744>\
**Category:** Help\
**Tags:** incremental\
**Created:** [August 28, 2023, 8:45pm UTC](https://discourse.getdbt.com/t/incremental-model-fails-on-second-run/9744 "2023-08-28T20:45:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ytrom](https://avatars.discourse-cdn.com/v4/letter/y/54ee81/32.png) [@ytrom](https://discourse.getdbt.com/u/ytrom)\
**Post date:** [August 28, 2023, 8:45pm UTC](https://discourse.getdbt.com/t/incremental-model-fails-on-second-run/9744/1 "2023-08-28T20:45:55Z")

</div>

## The problem I’m having

I use a dbt model to transform data in a postgres db. When I run an incremental model more than once it runs into an error complaining about a missing column. The error occurs only when I define a unique key.

## The context of why I’m trying to do this

I use an incremental model to append new data to a table. In my understanding the dbt model has to be executed every time new data is loaded to the db.

## Some example code or error messages

This is my model:

```auto
{{ config(
  materialized='incremental',
  unique_key = ‘Date1, product’
  alias=‘units’
) }}

select
    mu.index,
    mu."Date1”,
    mu.product,
    mu.units
from {{ source('sc’,’table_raw’) }} mu
{% if is_incremental() %}
  where mu."Date1" > (select max("Date1") from {{ this }})
{% endif %}
order by product, mu."Date1"

```

This is the translated error :

> ERROR: Column »date1« does not exist  
> LINE 8: select (Date1, product)  
> ^  
> HINT: Perhaps the intention is to refer to column »units\_\_dbt\_tmp220418107752.Date1« or to the column »units.Date1«.
