-
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix expect_row_values_to_have_data_for_every_n_datepart errors when both start and end dates are set #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Hoping to cut a release this weekend, pending a related PR.
@@ -914,7 +914,13 @@ tests: | |||
|
|||
Expects model to have values for every grouped `date_part`. | |||
|
|||
For example, this tests whether a model has data for every `day` (grouped on `date_col`) from either a specified `start_date` and `end_date`, or for the `min`/`max` value of the specified `date_col`. | |||
For example, this tests whether a model has data for every `day` (grouped on `date_col`) between either: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeremyyeo fyi, just updated the README a bit. Thanks for adding the extra documentation!
@@ -5,7 +5,7 @@ | |||
name: 'dbt_expectations' | |||
version: '0.4.0' | |||
|
|||
require-dbt-version: [">=0.20.0", "<0.21.0"] | |||
require-dbt-version: [">=0.20.0", "<0.22.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, rebased to support 0.21
{%- set dr = run_query(sql) -%} | ||
{%- set db_start_date = dr.columns[0].values()[0].strftime('%Y-%m-%d') -%} | ||
{%- set db_end_date = dr.columns[1].values()[0].strftime('%Y-%m-%d') -%} | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* add `interval` argument for checking presence every n-date_parts instead of every date_part * update docs for explaining new `interval` arg [expect_row_values_to_have_data_for_every_n_datepart](https://github.com/calogica/dbt-expectations/tree/0.4.2#expect_row_values_to_have_data_for_every_n_datepart) * expect_table_columns_to_match_ordered_list: refactor row_number to use loop.index (#112) * Fixes #111 - refactor row_number to use loop.index * Update CHANGELOG * handle data types for `mod` and incorporate windowing This test will handle the mod function, which only takes integer arguments, more stably. It also aggregates row counts across intervals when joining on the date spine to correctly detect data presence in the target model update conditions based on interval update styling update styling * Add support for dbt 0.21 (#116) * Update README.md * remove unintentional styling changes * Fix expect_row_values_to_have_data_for_every_n_datepart errors when both start and end dates are set (#115) * fix none when both test dates are set * Add support for dbt 0.21 (#116) * Update README.md * fix none when both test dates are set * Update README Co-authored-by: Claus Herther <claus@calogica.com> * add `interval` argument for checking presence every n-date_parts instead of every date_part * update docs for explaining new `interval` arg [expect_row_values_to_have_data_for_every_n_datepart](https://github.com/calogica/dbt-expectations/tree/0.4.2#expect_row_values_to_have_data_for_every_n_datepart) * handle data types for `mod` and incorporate windowing This test will handle the mod function, which only takes integer arguments, more stably. It also aggregates row counts across intervals when joining on the date spine to correctly detect data presence in the target model update conditions based on interval update styling update styling * remove unintentional styling changes * Change datepart param and fix formatting * Reformat join to match prior style * simplify tie-out of model data to spine with interval truncation the condition added to the model_data CTE is meant to emulate (kind of) Snowflake's [`TIME_SLICE`](https://docs.snowflake.com/en/sql-reference/functions/time_slice.html), which should allow exact matches to the base_dates CTE for better time bucketing * Add schema test * replace calls to subquery with calls directly to columns in `model_data` CTE * add comments/examples for new interval additions Co-authored-by: Claus Herther <claus@calogica.com> Co-authored-by: Jeremy Yeo <jeremyyeo@users.noreply.github.com>
Hey @clausherther, just implementing @barberscott's fix for #113 here.
Tested with the following:
model / schema
dbt test -m dim_dates
output