# does a full refresh enforce an incremental model unique key?

**URL:** <https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891>\
**Category:** Help\
**Tags:** incremental, snowflake\
**Created:** [August 15, 2024, 3:22pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891 "2024-08-15T15:22:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtrudel](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jtrudel/32/4237_2.png) [@jtrudel](https://discourse.getdbt.com/u/jtrudel)\
**Post date:** [August 15, 2024, 3:22pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891/1 "2024-08-15T15:22:44Z")

</div>

Hey all!

very simple question:

when you trigger a full refresh on an incremental model, is the unique key constraint of uniqueness and non-null still enforced? Only thing I found in the doc is full refresh treats your model like a regular table, so I wasn’t sure of the behavior.

Thanks!

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [August 15, 2024, 3:29pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891/2 "2024-08-15T15:29:32Z")

</div>

dbt does not verify the uniqueness of the fields listed in the `unique_key` config. If you want to verify that it’s actually unique, use a \<[Add data tests to your DAG | dbt Developer Hub](https://docs.getdbt.com/docs/build/data-tests#generic-data-tests%7Cdata) test\> or a \<[Model contracts | dbt Developer Hub](https://docs.getdbt.com/docs/collaborate/govern/model-contracts#platform-constraint-support%7Cdata) model constraint\> (but unique constraints are only enforced on Postgres currently)

The `unique_key` config for an incremental model just tells dbt what fields to join on for a merge operation. [https://docs.getdbt.com/docs/build/incremental-models#defining-a-unique-key-optional](https://docs.getdbt.com/docs/build/incremental-models#defining-a-unique-key-optional)

Note: `@Owen` originally [posted this reply in Slack](https://getdbt.slack.com/archives/CBSQTAPLG/p1723735764790799?thread_ts=1723735386.170159&cid=CBSQTAPLG). It might not have transferred perfectly.

---

<div class="post-metadata">

**Author:** ![jtrudel](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jtrudel/32/4237_2.png) [@jtrudel](https://discourse.getdbt.com/u/jtrudel)\
**Post date:** [August 15, 2024, 3:48pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891/3 "2024-08-15T15:48:25Z")

</div>

> [@a\_slack\_user](#):
>
> [Add data tests to your DAG | dbt Developer Hub](https://docs.getdbt.com/docs/build/data-tests#generic-data-tests%7Cdata)

Okay thanks! So I can add a data\_test that would verify for uniqueness, but I wouldn’t need one for not\_null since that one is handled by the incremental model, correct?

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [August 15, 2024, 4:01pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891/4 "2024-08-15T16:01:03Z")

</div>

I don’t know that the `unique_key` config implies any runtime constraints (unique, non-null). As far as I know, you need to validate such things yourself. Although most database platforms support enforcing non-null constraints via dbt model contracts.

Note: `@Owen` originally [posted this reply in Slack](https://getdbt.slack.com/archives/CBSQTAPLG/p1723737645346549?thread_ts=1723735386.170159&cid=CBSQTAPLG). It might not have transferred perfectly.

---

<div class="post-metadata">

**Author:** ![jtrudel](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jtrudel/32/4237_2.png) [@jtrudel](https://discourse.getdbt.com/u/jtrudel)\
**Post date:** [August 15, 2024, 6:04pm UTC](https://discourse.getdbt.com/t/does-a-full-refresh-enforce-an-incremental-model-unique-key/14891/5 "2024-08-15T18:04:29Z")

</div>

For the incremental, it fails if the unique keys contains nulls. That part is written in the docs
