Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to retrieve contract enforced from dict #694

Merged
merged 6 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .changes/1.5.0/Under the Hood-20230223-105838.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230223-105838.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Treat contract config as a python object
time: 2023-02-23T10:58:38.092981-05:00
custom:
Author: gshank emmyoop
Issue: 645 693
9 changes: 6 additions & 3 deletions dbt/include/spark/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@
{% else %}
create table {{ relation }}
{% endif %}
{% if config.get('contract', False) %}
{%- set contract_config = config.get('contract') -%}
{%- if contract_config.enforced -%}
{{ get_assert_columns_equivalent(compiled_code) }}
{%- set compiled_code = get_select_subquery(compiled_code) %}
{% endif %}
Expand Down Expand Up @@ -180,7 +181,8 @@
{% endmacro %}

{% macro spark__persist_constraints(relation, model) %}
{% if config.get('contract', False) and config.get('file_format', 'delta') == 'delta' %}
{%- set contract_config = config.get('contract') -%}
{% if contract_config.enforced and config.get('file_format', 'delta') == 'delta' %}
{% do alter_table_add_constraints(relation, model.columns) %}
{% do alter_column_set_constraints(relation, model.columns) %}
{% endif %}
Expand Down Expand Up @@ -229,7 +231,8 @@
{% macro spark__create_view_as(relation, sql) -%}
create or replace view {{ relation }}
{{ comment_clause() }}
{% if config.get('contract', False) -%}
{%- set contract_config = config.get('contract') -%}
{%- if contract_config.enforced -%}
{{ get_assert_columns_equivalent(sql) }}
{%- endif %}
as
Expand Down