Skip to content

Instantly share code, notes, and snippets.

@drewbanin
Created January 15, 2019 02:31
Show Gist options
  • Save drewbanin/931e85bd995f3edecec7755eb0488571 to your computer and use it in GitHub Desktop.
Save drewbanin/931e85bd995f3edecec7755eb0488571 to your computer and use it in GitHub Desktop.
{% macro generate_base_test(relation, primary_key=none) %}
{% set cols = adapter.get_columns_in_table(relation) %}
version: 2
models:
- name: {{relation.name}}
description: "Data from {{relation.schema}}.{{relation.table}}."
columns:
{% for col in cols %}
- name: {{ col.name }}
description: {% if col.name == primary_key -%}
"The primary key for this model"
{%- else -%}
"TODO"
{%- endif %}
{% if col.name == primary_key -%}
tests:
- unique
- not_null
{%- else -%}
tests: []
{%- endif %}
{% endfor %}
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment