Primary Keys
Validate the model has at least one column with a unique and not_null test
Source code in checkers/checks.py
Reason to flag#
A primary key test ensures that every table has a single column with unique, not null values. These primary keys are important for debugging issues, and helpful for features like snapshotting. We recommend every model define a primary key.
Fixing#
Add a unique and not_null test to one of the model's columns.
Example yaml entry:
models:
- name: user
description: A model representing all the product's users
columns:
- name: user_id
tests:
- unique
- not_null
Parameters#
N/A