Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions macros/math/log_natural.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@
ln({{ x }})

{%- endmacro -%}

{% macro sqlserver__log_natural(x) -%}

log({{ x }})

{%- endmacro -%}
4 changes: 4 additions & 0 deletions macros/schema_tests/_generalized/_truth_expression.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
{% macro default__truth_expression(expression) %}
{{ expression }} as expression
{% endmacro %}

{% macro sqlserver__truth_expression(expression) %}
case when {{ expression }} then 1 else 0 end as expression
{% endmacro %}
39 changes: 39 additions & 0 deletions macros/schema_tests/_generalized/expression_is_true.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,43 @@ select *
from validation_errors


{% endmacro -%}

{% macro sqlserver__expression_is_true(model, expression, test_condition, group_by_columns, row_condition) -%}
with grouped_expression as (
select
{% if group_by_columns %}
{% for group_by_column in group_by_columns -%}
{{ group_by_column }} as col_{{ loop.index }},
{% endfor -%}
{% endif %}
{{ dbt_expectations.truth_expression(expression) }}
from {{ model }}
{%- if row_condition %}
where
{{ row_condition }}
{% endif %}
{% if group_by_columns %}
group by
{% for group_by_column in group_by_columns -%}
{{ group_by_column }}{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}

),
validation_errors as (

select
*
from
grouped_expression
where
not(expression =1)

)

select *
from validation_errors


{% endmacro -%}
Loading