Skip to main content
Datafold supports composite primary keys, meaning that you can assign multiple columns that make up the primary key together.

Metadata

The first option is setting the primary-key key in the dbt metadata. There are several ways to configure this in your dbt project using either the meta key in a yaml file or a model-specific config block.

Tags

If the primary key is not found in the metadata, it will go through the tags.

Inferred

If the primary key isn’t provided explicitly, Datafold will try to infer a primary key from dbt’s uniqueness tests. If you have a single column uniqueness test defined, it will use this column as the PK.
Also, model-level uniqueness tests can be used for inferring the PK.
Keep in mind that this is a failover mechanism. If you change the uniqueness test, this will also impact the way Datafold performs the diff.