-
Notifications
You must be signed in to change notification settings - Fork 510
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
Create/update a macro to verify sum of row counts of n relations #940
Comments
@aranke Thanks for raising this issue and linking those two other places where this has come up! If the model is really that simple, what would be the value of a data test here? Wouldn't the counts be guaranteed to be equal? I don't see how the count of rows could be anything but exactly the same in this case. |
Hi adding my 2 cents here and I raised this with dbt support too. It's useful in our case when the unioned model is incremental. |
Thanks for that info @edmei1 ! Could you share an example model that shows more detail? Something like this:
{{
config(
materialized='incremental'
)
}}
with unioned_models as (
select * from {{ ref('stg_my_source_a') }}
union all
select * from {{ ref('stg_my_source_b') }}
union all
select * from {{ ref('stg_my_source_c') }}
)
select *
from unioned_models
{% if is_incremental() %}
where event_time >= (select coalesce(max(event_time),'1900-01-01') from {{ this }} )
{% endif %} |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
1 similar comment
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Describe the feature
There are situations where a model simply is a
union all
of various other models:In this example, it would be useful to have a 1:many test to verify that:
Describe alternatives you've considered
equal_rowcount
is the closest thing indbt-utils
, but only does 1:1 relationsAdditional context
I don't think this feature is database-specific.
Who will this benefit?
This feature has been requested several times over the years (dbt internal Slack, previous GitHub issue); this feature will benefit those users.
Are you interested in contributing to this feature?
Sure, happy to help.
The text was updated successfully, but these errors were encountered: