diff --git a/integration_tests/data/schema_tests/data_test_expression_is_true_1.csv b/integration_tests/data/schema_tests/data_test_expression_is_true.csv similarity index 100% rename from integration_tests/data/schema_tests/data_test_expression_is_true_1.csv rename to integration_tests/data/schema_tests/data_test_expression_is_true.csv diff --git a/integration_tests/data/schema_tests/data_test_expression_is_true_2.csv b/integration_tests/data/schema_tests/data_test_expression_is_true_window_functions.csv similarity index 100% rename from integration_tests/data/schema_tests/data_test_expression_is_true_2.csv rename to integration_tests/data/schema_tests/data_test_expression_is_true_window_functions.csv diff --git a/integration_tests/models/schema_tests/schema.yml b/integration_tests/models/schema_tests/schema.yml index 53c67638..417850ac 100644 --- a/integration_tests/models/schema_tests/schema.yml +++ b/integration_tests/models/schema_tests/schema.yml @@ -13,7 +13,7 @@ models: tests: - dbt_utils.at_least_one - - name: data_test_expression_is_true_1 + - name: data_test_expression_is_true tests: - dbt_utils.expression_is_true: expression: col_a + col_b = 1 @@ -31,7 +31,7 @@ models: expression: = 0.5 condition: col_a = 0.5 - - name: data_test_expression_is_true_2 + - name: data_test_expression_is_true_window_functions tests: - dbt_utils.expression_is_true: expression: count(*) over (partition by col_a) = 2 diff --git a/macros/schema_tests/expression_is_true.sql b/macros/schema_tests/expression_is_true.sql index 98a47bc8..29bc3470 100644 --- a/macros/schema_tests/expression_is_true.sql +++ b/macros/schema_tests/expression_is_true.sql @@ -6,15 +6,6 @@ {% macro default__test_expression_is_true(model, expression, column_name, condition) %} -{% if execute %} - {%- set columns = adapter.get_columns_in_relation(model) -%} - {% for col in columns %} - {{ exceptions.raise_compiler_error( - '_test_expression_passed is a protected column name for the dbt_utils.expression_is_true test.\nPlease rename the `_test_expression_passed` field in ' ~ model.name ~'.' - ) if '_test_expression_passed' == col.name|lower }} - {% endfor %} -{% endif %} - with meet_condition as ( select *, @@ -23,11 +14,12 @@ with meet_condition as ( {%- else %} {{ column_name }} {{ expression }} {%- endif %} - as _test_expression_passed + as _dbt_utils_test_expression_passed from {{ model }} where {{ condition }} ) -select * from meet_condition where not(_test_expression_passed) +select * from meet_condition +where not(_dbt_utils_test_expression_passed) {% endmacro %}