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

support contracts on models materialized as view #500

Merged
merged 7 commits into from
Mar 8, 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: 3 additions & 3 deletions .changes/unreleased/Features-20230223-182450.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kind: Features
body: implement data_type_code_to_name on SnowflakeConnectionManager
body: Enforce contracts on models materialized as tables and views
time: 2023-02-23T18:24:50.272955-05:00
custom:
Author: michelleark
Issue: "464"
Author: michelleark emmyoop
Issue: 464 490
3 changes: 3 additions & 0 deletions dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
{{ get_persist_docs_column_list(model_columns, query_columns) }}

{%- endif %}
{% if config.get('contract', False) -%}
{{ get_assert_columns_equivalent(sql) }}
{%- endif %}
{% if copy_grants -%} copy grants {%- endif %} as (
{{ sql }}
);
Expand Down
13 changes: 10 additions & 3 deletions tests/functional/adapter/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from dbt.tests.util import relation_from_name
from dbt.tests.adapter.constraints.test_constraints import (
BaseConstraintsColumnsEqual,
BaseTableConstraintsColumnsEqual,
BaseViewConstraintsColumnsEqual,
BaseConstraintsRuntimeEnforcement
)

Expand All @@ -21,8 +22,7 @@
"""


class TestSnowflakeConstraintsColumnsEqual(BaseConstraintsColumnsEqual):

class SnowflakeColumnEqualSetup:
@pytest.fixture
def int_type(self):
return "FIXED"
Expand All @@ -46,6 +46,13 @@ def data_types(self, int_type, schema_int_type, string_type):
["""TO_VARIANT(PARSE_JSON('{"key3": "value3", "key4": "value4"}'))""", 'variant', 'VARIANT'],
]

class TestSnowflakeTableConstraintsColumnsEqual(SnowflakeColumnEqualSetup, BaseTableConstraintsColumnsEqual):
pass


class TestSnowflakeViewConstraintsColumnsEqual(SnowflakeColumnEqualSetup, BaseViewConstraintsColumnsEqual):
pass


class TestSnowflakeConstraintsRuntimeEnforcement(BaseConstraintsRuntimeEnforcement):

Expand Down