Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename check to constraints_check
  • Loading branch information
b-per authored and jtcohen6 committed Feb 1, 2023
commit 0d2887ceef074c92590116f32b464ee6dd13818d
4 changes: 2 additions & 2 deletions dbt/include/snowflake/macros/utils/get_columns_spec_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
{% for i in user_provided_columns -%}
{%- set col = user_provided_columns[i] -%}
{% set constraints = col['constraints'] -%}
{%- set ns.at_least_one_check = ns.at_least_one_check or col['check'] %}
{%- set ns.at_least_one_check = ns.at_least_one_check or col['constraints_check'] %}
{{ col['name'] }} {{ col['data_type'] }} {% for x in constraints %} {{ x or "" }} {% endfor %} {{ "," if not loop.last }}
{%- endfor %}
)
{%- if ns.at_least_one_check -%}
{{exceptions.warn("We noticed you have `check` configs, these are NOT compatible with Snowflake and will be ignored")}}
{{exceptions.warn("We noticed you have `constraints_check` configs, these are NOT compatible with Snowflake and will be ignored")}}
{%- endif %}
{% endif %}
{% endmacro %}
10 changes: 5 additions & 5 deletions tests/functional/constraints/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
constraints:
- unique
- not null
check: "int_column > 0"
constraints_check: "int_column > 0"
- name: float_column
description: "Test for int type"
data_type: float
check: "float_column > 0"
constraints_check: "float_column > 0"
- name: bool_column
description: "Test for int type"
data_type: boolean
Expand Down Expand Up @@ -123,9 +123,9 @@ def project_config_update(self, prefix):

def test_materialized_with_constraints(self, project):
_, stdout = run_dbt_and_capture(["run", "--select", "constraints_column_types"])
found_check_config_str = "We noticed you have `check` configs"
number_times_print_found_check_config = stdout.count(found_check_config_str)
assert number_times_print_found_check_config == 1
found_constraints_check_config_str = "We noticed you have `constraints_check` configs"
number_times_print_found_constraints_check_config = stdout.count(found_constraints_check_config_str)
assert number_times_print_found_constraints_check_config == 1

def test_failing_materialized_with_constraints(self, project):
result = run_dbt(
Expand Down