-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from calogica/fix/issue-22-datatype
Refactor column type checks to use dtype
- Loading branch information
Showing
2 changed files
with
3 additions
and
17 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
18 changes: 2 additions & 16 deletions
18
macros/schema_tests/column_values_basic/expect_column_values_to_be_of_type.sql
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 |
---|---|---|
@@ -1,18 +1,4 @@ | ||
{%- macro test_expect_column_values_to_be_of_type(model, column_name, column_type) -%} | ||
{%- if execute -%} | ||
|
||
{%- set column_name = column_name | upper -%} | ||
{%- set columns_in_relation = adapter.get_columns_in_relation(model) -%} | ||
{%- set column_type = column_type| upper -%} | ||
|
||
{%- set matching_column_types = [] -%} | ||
|
||
{%- for column in columns_in_relation -%} | ||
{%- if ((column.name | upper ) == column_name) and ((column.data_type | upper ) == column_type) -%} | ||
{%- do matching_column_types.append(column.name) -%} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
select 1 - {{ matching_column_types | length }} | ||
|
||
{%- endif -%} | ||
{{ dbt_expectations.test_expect_column_values_to_be_in_type_list(model, column_name, [column_type]) }} | ||
{%- endmacro -%} | ||
|