Skip to content

Commit d87c366

Browse files
authored
Emit true null (not blank) for absent test min/max (#76)
The quoted '{{ null if ... }}' idiom writes a blank string, not a SQL null, for absent numeric values -- which then errors on downstream cast on plain- cast adapters. Emit min/max unquoted as the value or a bare null instead.
1 parent d7e5e86 commit d87c366

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

macros/upload_tests.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
'{{ null if test_model is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_model | string) }}', {# test_model #}
9494
'{{ null if test_combination is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_combination | string) }}', {# test_combination_of_columns #}
9595
'{{ null if test_column_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_column_value | string) }}', {# test_column_value #}
96-
'{{ null if test_min_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_min_value | string) }}', {# test_column_min_value #}
97-
'{{ null if test_max_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_max_value | string) }}', {# test_column_max_value #}
96+
{{ "'" ~ test_min_value ~ "'" if test_min_value is not none else 'null' }}, {# test_column_min_value -- bare null (not blank) so it casts cleanly downstream #}
97+
{{ "'" ~ test_max_value ~ "'" if test_max_value is not none else 'null' }}, {# test_column_max_value -- bare null (not blank) so it casts cleanly downstream #}
9898
'{{ null if test_from_condition is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_from_condition | string) }}', {# test_relationship_from_model_condition #}
9999
'{{ null if test_to_model is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_to_model | string) }}', {# test_to_model #}
100100
'{{ null if test_to_field is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_to_field | string) }}', {# test_relationship_to_field #}
@@ -161,8 +161,8 @@
161161
'{{ null if test_model is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_model | string) }}', {# test_model #}
162162
'{{ null if test_combination is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_combination | string) }}', {# test_combination_of_columns #}
163163
'{{ null if test_column_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_column_value | string) }}', {# test_column_value #}
164-
'{{ null if test_min_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_min_value | string) }}', {# test_column_min_value #}
165-
'{{ null if test_max_value is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_max_value | string) }}', {# test_column_max_value #}
164+
{{ "'" ~ test_min_value ~ "'" if test_min_value is not none else 'null' }}, {# test_column_min_value -- bare null (not blank) so it casts cleanly downstream #}
165+
{{ "'" ~ test_max_value ~ "'" if test_max_value is not none else 'null' }}, {# test_column_max_value -- bare null (not blank) so it casts cleanly downstream #}
166166
'{{ null if test_from_condition is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_from_condition | string) }}', {# test_relationship_from_model_condition #}
167167
'{{ null if test_to_model is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_to_model | string) }}', {# test_to_model #}
168168
'{{ null if test_to_field is none else adapter.dispatch('escape_singlequote', 'dbt_observability')(test_to_field | string) }}', {# test_relationship_to_field #}

0 commit comments

Comments
 (0)