-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ensure reporting.vw_pin_most_recent_sale
rowcount is correct before ias rollover
#698
Ensure reporting.vw_pin_most_recent_sale
rowcount is correct before ias rollover
#698
Conversation
AND deactivat IS NULL | ||
-- noqa: disable=RF02 |
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.
There may be a bug in RF02 in our version of SQLFluff, since this block doesn't seem to me to represent an unqualified reference. It doesn't raise an error, but the warning is annoying, so I ignore it just for this block.
# Rowcount will typically exceed iasworld.pardat due to sales with | ||
# PINs that are not in pardat, but at a minimum we want one row | ||
# for each PIN that we know about in pardat |
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.
We could make this even more accurate by joining to pardat
by PIN, but that would make the test more complicated and I think the simple rowcount is good enough to catch cases like the one that inspired this PR.
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 for fixing this @jeancochrane. I should check our other views from any use of CURRENT_DATE
that might lead to similar issues.
I took a quick look, and everything else that uses |
The
reporting.vw_pin_most_recent_sale
view currently has the wrong number of rows since its query filtersiasworld.pardat
byYEAR(CURRENT_DATE)
, but we don't have 2025 data in iasWorld as the rollover hasn't happened yet. We got notified of this bug by our weekly tests, which failed this morning.This PR updates
reporting.vw_pin_most_recent_sale
so that it filters pardat for the most recent available year in that table. It also simplifies the rowcount tests for the model to be more accurate and easier to debug.