-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
After upgrading to 1.8, i.e. latest version on dbt cloud, the tests seem to have stopped running correctly on my schema when I run on my production environment. This worked as intended in 1.7. It works fine on 1.8 in the dev environment.
Some tests seem to pass correctly and some don't, I haven't been able to find a pattern.
Note:
I am using https://docs.getdbt.com/docs/build/custom-schemas, under macros/generate_schema_name.sql, however it seems to apply the tests on the generated schemas so not sure if it is related at all.
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if target.name == 'prod' or target.name == 'test' -%}
{%- if custom_schema_name is none -%}
{# Check if the model does not contain a subfolder (e.g, models created at the MODELS root folder) #}
{% if node.fqn[1:-1]|length == 0 %}
{{ default_schema }}
{% else %}
{# Concat the subfolder(s) name #}
{% set prefix = node.fqn[1:-1]|join('_') %}
{{ prefix | trim }}
{% endif %}
{%- else -%}
{{ default_schema }}_{{ custom_schema_name | trim }}
{%- endif -%}
{%- else -%}
{# Always use default schema for other environments #}
{{ default_schema }}
{%- endif -%}
{%- endmacro %}
Some examples of tests in my models.yml file:
version: 2
models:
- name: stg_bc__customers
description: Customer data.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- "companyno"
- "no"
columns:
- name: "no"
tests:
- not_null
- name: stg_bc__customerledgerentries
description: Customer ledger entries.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- "companyno"
- "entryno"
columns:
- name: "entryno"
tests:
- not_null
debug (34).log
console_output (16).log

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels