Skip to content

Commit

Permalink
a few more macro fixes and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebruyn committed Sep 7, 2024
1 parent 57526f9 commit 0e24891
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 deletions.
8 changes: 8 additions & 0 deletions integration_tests/dbt_audit_helper/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
packages:
- local: ../../
- local: ../../dbt-audit-helper
- local: ../../dbt-audit-helper/integration_tests
- package: dbt-labs/dbt_utils
version: 1.3.0
- local: ../
sha1_hash: 6514ce239efacea424bc5221ed12aa46aedc35e8
2 changes: 1 addition & 1 deletion integration_tests/dbt_date/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dispatch:
["tsql_utils_dbt_date_integration_tests", "tsql_utils", "dbt", "dbt_date"]

vars:
"dbt_date:time_zone": "Pacific Standard Time"
"dbt_date:time_zone": "UTC"

models:
dbt_date_integration_tests:
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/dbt_date/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages:
- local: ../../
- local: ../../dbt-date
- local: ../../dbt-date/integration_tests
- local: ../
sha1_hash: 23e06fdd28a6456704c5398f7e588a034e2a03de
2 changes: 1 addition & 1 deletion integration_tests/dbt_expectations/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dispatch:
]

vars:
"dbt_date:time_zone": "Pacific Standard Time"
"dbt_date:time_zone": "UTC"

models:
dbt_expectations_integration_tests:
Expand Down
8 changes: 8 additions & 0 deletions integration_tests/dbt_expectations/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
packages:
- local: ../../
- local: ../../dbt-expectations
- local: ../../dbt-expectations/integration_tests
- package: calogica/dbt_date
version: 0.10.1
- local: ../
sha1_hash: 5723a05ef1d9b9d1f7961a55d573231dca0b0644
13 changes: 4 additions & 9 deletions integration_tests/dbt_utils/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ models:
enabled: false
test_url_path: *disabled
test_urls: *disabled
cross_db_utils: *disabled
sql:
test_generate_series: *disabled
test_get_column_values: *disabled
Expand All @@ -34,25 +33,21 @@ models:
test_groupby: *disabled
test_union: *disabled
test_unpivot_bool: *disabled
materializations:
test_insert_by_period: *disabled
test_get_single_value: *disabled
test_get_single_value_default: *disabled

data_tests:
dbt_utils_integration_tests: *disabled

seeds:
dbt_utils_integration_tests:
cross_db: *disabled
schema_tests:
data_test_sequential_timestamps:
+column_types:
my_timestamp: datetime2
data_test_unique_where: *disabled
data_test_not_null_where: *disabled
data_test_sequential_timestamps: *disabled
data_test_mutually_exclusive_ranges_with_gaps_zero_length: *disabled
data_test_mutually_exclusive_ranges_no_gaps: *disabled
data_test_mutually_exclusive_ranges_with_gaps: *disabled

sql:
data_unpivot_bool: *disabled
data_unpivot_bool_expected: *disabled
data_get_single_value: *disabled
33 changes: 24 additions & 9 deletions macros/dbt_utils/schema_tests/sequential_values.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
{% macro fabric__test_sequential_values(model, column_name, interval=1, datepart=None) %}
{% macro fabric__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}

{% if group_by_columns|length() > 0 %}
{% set select_gb_cols = group_by_columns|join(',') + ', ' %}
{% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}
{% endif %}

with windowed as (

select
*
from (
select
{{ select_gb_cols }}
{{ column_name }},
lag({{ column_name }}) over (
{{partition_gb_cols}}
order by {{ column_name }}
) as previous_{{ column_name }}
from {{ model }}
) required_alias_for_tsql
) as {{ previous_column_name }}
from {{ model }} required_alias_for_tsql
),

validation_errors as (
select
*
from windowed
{% if datepart %}
where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, 'previous_' + column_name) }} as {{ dbt.type_timestamp() }}))
where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))
{% else %}
where not({{ column_name }} = previous_{{ column_name }} + {{ interval }})
where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})
{% endif %}
)

select *
from validation_errors

{% endmacro %}

0 comments on commit 0e24891

Please sign in to comment.