-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on contract constraints
Initial work on dbt constraints using contracts. Items to note: * contracts do not appear to be enforced if model schema.yml is namespaced with dbt_business_intelligence * main fix here is addition of fabric__table_columns_and_constraints macro, which is a redirect to get around this issue: dbt-msft/dbt-sqlserver#494
- Loading branch information
Showing
7 changed files
with
574 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% macro fabric__table_columns_and_constraints(relation) -%} | ||
{%- do log("REDIRECT!!!: " ~ relation, info=true) -%} | ||
{{ fabric__build_columns_constraints(relation) }} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{%- macro sqlserver__generate_surrogate_key(field_list) -%} | ||
|
||
{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%} | ||
{%- set default_null_value = "" -%} | ||
{%- else -%} | ||
{%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%} | ||
{%- endif -%} | ||
|
||
{%- set fields = [] -%} | ||
|
||
{%- for field in field_list -%} | ||
|
||
{%- do fields.append( | ||
"coalesce(cast(" ~ field ~ " as " ~ dbt.type_string() ~ "), '" ~ default_null_value ~"')" | ||
) -%} | ||
|
||
{%- if not loop.last %} | ||
{%- do fields.append("'-'") -%} | ||
{%- endif -%} | ||
|
||
{%- endfor -%} | ||
|
||
{%- if fields|length > 1 %} | ||
{{ dbt.hash(dbt.concat(fields)) }} | ||
{%- else -%} | ||
{{ dbt.hash(fields[0]) }} | ||
{%- endif -%} | ||
|
||
{%- endmacro -%} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.