-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow for overriding of current_timestamp to a static value #48
Comments
@mkkuba thanks for submitting this. Good idea! The issue you're facing is that you have a column using Here's one idea: have you tried using the |
@mjirv thank you for the quick response. The issue is that our transform itself uses the value of
(joining a date dimension table up to a certain timestamp) Another potential use case might be having an event stream but only wanting the last hour of events (and the test would confirm you weren't selecting more than the past hour of events) |
Got it, that makes sense. We can definitely work on this. Thanks! |
You can also substitute your non-deterministic function calls with hardcoded values that you will use in your testing environment (for example, some kind of CI env) WITH
dates AS (
SELECT dd AS group_date
{%- if target.name == 'ci' %} -- used in unit testing
FROM GENERATE_SERIES('2021-02-13'::DATE, '2021-02-13'::DATE, INTERVAL '1 days') AS dd
{%- else %} -- used in production
FROM GENERATE_SERIES(CURRENT_DATE - 1, CURRENT_DATE - 1, INTERVAL '1 days') AS dd
{%- endif %}
), |
Describe the feature
Allow for overriding of
{{ dbt_utils.current_timestamp() }}
to a static valueDescribe alternatives you've considered
I have not been able to think of straight forward alternatives to easily do this.
This could also be useful for overriding of dbt functions in general (e.g.
{{ var('my_variable') }}
)Who will this benefit?
This is useful for testing dbt transformations that are dependent on the current timestamp
Are you interested in contributing this feature?
No
The text was updated successfully, but these errors were encountered: