From dcdee8970bb904fe4780e28285a524bdbe7f0f57 Mon Sep 17 00:00:00 2001 From: Camron B Date: Sat, 20 Jan 2024 02:45:57 -0700 Subject: [PATCH 1/3] Update equal_expression.sql Adding aliases to override of dbt_expectations equal_expression.sql file, would not allow creation of views without specifying column name --- .../schema_tests/_generalized/equal_expression.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql index 1ea1a1d..00f434a 100644 --- a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql +++ b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql @@ -72,9 +72,9 @@ -- select * from final select {% if return_difference %} - coalesce(sum(expression_difference), 0) + coalesce(sum(expression_difference), 0) as final_expression {% else %} - count(*) + count(*) as final_expression {% endif %} from final where From 61d69e6cf79e3ce240768334cdf3a69e88ad67d7 Mon Sep 17 00:00:00 2001 From: Camron B Date: Sat, 20 Jan 2024 10:10:30 -0700 Subject: [PATCH 2/3] Update equal_expression.sql Actually, if you want to use this in a test, you can't use count(*) or sum(*) since they will always return a value and therefore fail every test --- .../schema_tests/_generalized/equal_expression.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql index 00f434a..7b3d258 100644 --- a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql +++ b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql @@ -72,9 +72,9 @@ -- select * from final select {% if return_difference %} - coalesce(sum(expression_difference), 0) as final_expression + coalesce(expression_difference, 0) as test_results {% else %} - count(*) as final_expression + * as test_results {% endif %} from final where From 5e7a81cd828503dee256fda69f3903efa3a42557 Mon Sep 17 00:00:00 2001 From: Camron B Date: Mon, 22 Jan 2024 16:18:35 -0700 Subject: [PATCH 3/3] Update equal_expression.sql Matching the signature definition to the latest change, found here: https://github.com/calogica/dbt-expectations/pull/135 --- .../schema_tests/_generalized/equal_expression.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql index 7b3d258..4fee082 100644 --- a/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql +++ b/macros/dbt_expectations/schema_tests/_generalized/equal_expression.sql @@ -22,7 +22,9 @@ {% endif %} {% endmacro -%} -{%- macro sqlserver__test_equal_expression(model, expression, +{%- macro sqlserver__test_equal_expression( + model, + expression, compare_model, compare_expression, group_by, @@ -30,8 +32,7 @@ row_condition, compare_row_condition, tolerance, - tolerance_percent, - return_difference) -%} + tolerance_percent) -%} {%- set compare_model = model if not compare_model else compare_model -%} {%- set compare_expression = expression if not compare_expression else compare_expression -%} @@ -71,11 +72,7 @@ -- DEBUG: -- select * from final select - {% if return_difference %} - coalesce(expression_difference, 0) as test_results - {% else %} - * as test_results - {% endif %} + * from final where {% if tolerance_percent %}