From 3ee44b36449caffd276c036c507cefec87617ee9 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Sun, 7 Apr 2024 17:48:49 -0400 Subject: [PATCH] Check expected_sql instead of expected_rows --- .../macros/materializations/tests/unit.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dbt/include/global_project/macros/materializations/tests/unit.sql b/dbt/include/global_project/macros/materializations/tests/unit.sql index 7d579063..78c6f6bc 100644 --- a/dbt/include/global_project/macros/materializations/tests/unit.sql +++ b/dbt/include/global_project/macros/materializations/tests/unit.sql @@ -15,11 +15,10 @@ {%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%} {%- endfor -%} - {%- if expected_rows -%} - {%- set expected_sql = get_expected_sql(expected_rows, column_name_to_data_types) -%} - {%- endif -%} - - {%- set unit_test_sql = get_unit_test_sql(sql, expected_sql, tested_expected_column_names) -%} + {% if not expected_sql %} + {% set expected_sql = get_expected_sql(expected_rows, column_name_to_data_types) %} + {% endif %} + {% set unit_test_sql = get_unit_test_sql(sql, expected_sql, tested_expected_column_names) %} {% call statement('main', fetch_result=True) -%}