-
Notifications
You must be signed in to change notification settings - Fork 47
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
[SEMANTIC-88] [Bug] window with time_grain=day extends beyond current date #187
Comments
Hi @JoeryV ! You have powers of prophecy because this was actually identified in a previous issue #181 and fixed in #183. This will go out by EOD in the new 1.3.2 release. The fix for this was changing the |
Hi @callum-mcdata, Thanks for the quick reply! I think that #181 was a separate issue from the one above. The issue here is that the window range is being extended into the future whereas #181 is about an extra day of history being considered bc of the inclusive Glancing over the code from #183, I don't this the above issue was solved yet. Unfortunately, I cannot test it atm as we are using the docker image dbt-snowflake which is currently stuck at |
@JoeryV do you mind testing this again? The issue with I am a bit curious to know how future dates could be picked up if the number wasn't defined as a negative value. I'm abstracting a bit but the code should compile down to something like the following, which would give you 7 previous days of data up to the "current_date" of whatever the row was.
So I'm not entirely sure how it would show future values if the value was set to |
@callum-mcdata First off, thank you for fixing the hub issue! 😄 I tried it with the new version and the issue persists. The reason for this issue is the following:
and this evaluates to |
I'm not sure what is causing it. Initially I thought it would be switching the |
Can you provide the SQL of the first two CTE's (aggregate & base)? We can take a look at the date joins and see what might be going on there that it would be throwing future dates into your dataset. Side note: I'm not sure but from this comment |
To the first point, this is the entire compiled sql for my
|
This one is tricky - I am unable to recreate it on my local. Can you return the results of |
Hi @callum-mcdata, I am not entirely sure what you mean by The date range is still being extended into the future. |
@JoeryV sorry I wasn't clear - can you return the results of just the CTE Additionally did you update your package to 1.3.2 or are you still on 1.3.1? |
Ah, sorry I didn't catch that. See the compiled query below: weekly_active_per_day__aggregate as (
select
date_day,
count(distinct property_to_aggregate) as weekly_active_per_day,
boolor_agg(metric_date_day is not null) as has_data
from (
select
cast(base_model.dim_date_day as date) as metric_date_day, -- timestamp field
calendar_table.date_day as date_day,
calendar_table.date_day as window_filter_date,
(dim_user_id) as property_to_aggregate
from analytics.dbt_jdevos.fct_sign_ins base_model
left join analytics.dbt_jdevos.dbt_metrics_default_calendar calendar_table
on cast(base_model.dim_date_day as date) > dateadd(day, -7, calendar_table.date_day)
and cast(base_model.dim_date_day as date) <= calendar_table.date_day
where 1=1
) as base_query
where 1=1
and date_day = window_filter_date
group by 1
) We are on the 1.3.2 version of |
AHHH - I think I finally understand what you mean and where this is coming from! It's not that the data is wrong but more that it is representing dates in the future. Got it 🤦 . Not sure why it took me this long to understand what exactly was the issue. All righty, so the reason that we're representing date's in the future is because the transaction on date This is because metrics have no concept of What I suspect you want is to use Does that make sense? |
@JoeryV following up on this one before I close out this issue! |
Hahah, thank you Callum! This was a good exercise in confusion. Thanks for the clear up! All good to close the issue. |
Is this a new bug in dbt_metrics?
Current Behavior
Using a rolling window extends past the current date into the future.
The following:
with the current date being
2022-11-18
, this query will result in the following output:As can be seen, the query extends 7 days into the future.
Expected Behavior
The max date in the output would be the current date.
Steps To Reproduce
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
Reason for this bug is probably caused in
genbase_query.sql
? The date in the base_model is defined as being relative tocalendar_table.date_day
instead of the reverse.The text was updated successfully, but these errors were encountered: