Skip to content

Commit

Permalink
remove dbt_utils references
Browse files Browse the repository at this point in the history
  • Loading branch information
clausherther committed Nov 20, 2022
1 parent 8585d8b commit 3330bc4
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 35 deletions.
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,7 @@ For latest release, see [https://github.com/calogica/dbt-expectations/releases](

### Dependencies

This package includes a reference to [`dbt-date`](https://github.com/calogica/dbt-date) which in turn references [`dbt-utils`](https://github.com/dbt-labs/dbt-utils) so there's no need to also import either `dbt-date` or `dbt-utils` in your local project.

Note: we no longer include `spark_utils` in this package to avoid versioning conflicts. If you are running this package on non-core platforms (outside of Snowflake, BigQuery, Redshift, Postgres), you will need to use a package like `spark_utils` to shim macros.

For example, in `packages.yml`, you will need to include the relevant package:

```yaml
- package: dbt-labs/spark_utils
version: <latest or range>
```
And reference in the dispatch list for `dbt_utils` in `dbt_project.yml`:

```yaml
vars:
dbt_utils_dispatch_list: [spark_utils]
```
This package includes a reference to [`dbt-date`](https://github.com/calogica/dbt-date), so there's no need to also import `dbt-date` in your local project.

### Variables

Expand Down Expand Up @@ -1137,7 +1121,7 @@ or, for example:
test_end_date: '{{ modules.datetime.date.today() - modules.datetime.timedelta(1) }}'
```

Unfortunately, you currently **cannot** use a dynamic SQL date, such as `current_date` or macro from a dbt package such as dbt-date, as the underlying `dbt_utils.date_spine` expects a date literal.
Unfortunately, you currently **cannot** use a dynamic SQL date, such as `current_date` or macro from a dbt package such as dbt-date, as the underlying `date_spine` macro expects a date literal.

The `interval` argument will optionally group `date_part` by a given integer to test data presence at a lower granularity, e.g. adding `interval: 7` to the example above will test whether a model has data for each 7-`day` period instead of for each `day`.

Expand Down
4 changes: 0 additions & 4 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ target-path: "target"
clean-targets: ["target", "dbt_packages"]
macro-paths: ["macros"]
log-path: "logs"

dispatch:
- macro_namespace: dbt_utils
search_order: ['dbt_expectations', 'dbt_utils'] # enable override
4 changes: 1 addition & 3 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ clean-targets: ["target", "dbt_modules", "dbt_packages"]
dispatch:
- macro_namespace: dbt_expectations
search_order: ['dbt_expectations_integration_tests', 'dbt_expectations']
- macro_namespace: dbt_utils
search_order: ['dbt_expectations', 'dbt_utils']

vars:
'dbt_date:time_zone': 'America/Los_Angeles'

quoting:
database: false
identifier: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ dbt_utils.generate_series(upper_bound=8) }}
{{ dbt_date.generate_series(upper_bound=8) }}
2 changes: 1 addition & 1 deletion integration_tests/models/schema_tests/series_10.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ dbt_utils.generate_series(upper_bound=10) }}
{{ dbt_date.generate_series(upper_bound=10) }}
2 changes: 1 addition & 1 deletion integration_tests/models/schema_tests/series_4.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ dbt_utils.generate_series(upper_bound=4) }}
{{ dbt_date.generate_series(upper_bound=4) }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ dbt_utils.date_spine('hour',
{{ dbt_date.date_spine('hour',
start_date=dbt_date.n_days_ago(10),
end_date=dbt_date.tomorrow()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ with metric_values as (
sum({{ column_name }}) as agg_metric_value
from
{{ model }}
{{ dbt_utils.group_by(1 + group_by_length) }}
{{ dbt_expectations.group_by(1 + group_by_length) }}

)
{%- if take_diffs %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with metric_values as (
from
{{ model }}
{% if group_by -%}
{{ dbt_utils.group_by(group_by | length) }}
{{ dbt_expectations.group_by(group_by | length) }}
{%- endif %}

),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ with latest_grouped_timestamps as (
{% endif %}

{% if group_by -%}
{{ dbt_utils.group_by(group_by | length) }}
{{ dbt_expectations.group_by(group_by | length) }}
{%- endif %}
),
total_row_counts as (
Expand All @@ -48,7 +48,7 @@ total_row_counts as (
from
latest_grouped_timestamps
{% if group_by -%}
{{ dbt_utils.group_by(group_by | length) }}
{{ dbt_expectations.group_by(group_by | length) }}
{%- endif %}


Expand Down
6 changes: 4 additions & 2 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages:
- package: calogica/dbt_date
version: [">=0.6.0", "<0.7.0"]
# - package: calogica/dbt_date
# version: [">=0.7.0", "<0.8.0"]
- git: "https://github.com/calogica/dbt-date.git"
revision: 0.7.0

0 comments on commit 3330bc4

Please sign in to comment.