-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 custom date for dbt_valid_to in snapshots #10187
Comments
Rough draft of YML: {{
config(
target_database='analytics',
target_schema='snapshots',
unique_key='id',
strategy='timestamp',
updated_at='updated_at',
#ideas
coalesce_dbt_valid_to='date(9999, 12, 31)',
dbt_valid_to_for_current_records='date(9999, 12, 31)' #default is NULL
future_date_dbt_valid_to=false,
coalesce_dbt_valid_to=dbt_max_date(),
coalesce_dbt_valid_to=var('dbt_max_date')
)
}}
|
Is it within scope to consider an altogether alternative strategy to
We also have a more complex use-case that alleviates some issues caused by extraction delays. For example, let's say that our extract failed for 2024-10-01:
Even though we extracted the record for this new key a day late, we'd like to reflect when it was generated by the source system for this first record. For subsequent records, we would follow more standard logic by using the Maybe this is too narrow to make it into dbt Core, but I figured I'd throw it out there. |
Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#6275 |
Description
Right now,
dbt_valid_to
is set toNULL
for current records.Some people, want to set
dbt_valid_to
to an arbitrary future date (so that their snapshot will work for a join, corporate standard, etc.).The way they do this today, is create a view on top of their snapshot:
Acceptance criteria
dbt_valid_to
for the current records in your snapshotNULL
(current behavior)"to_date('2024-05-10')"
'{{ var('my_future_date') }}'
'{{ dbt.date(9999, 12, 31) }}'
dbt_valid_to
is equal to for current records for the insertion logic when snapshotting, the existing snapshot must be updated before we can proceeddbt_is_current
column (as has been requested in another feature request) we could run a validation check to say "is every row withis_current = true
also havedbt_valid_to
equal to whatever I have set for mydbt_valid_to_for_current_records
config); could have a performance implicationstate:modified
we should throw a warning/error that this config has been updated (make them go in and manually update their existing snapshot)Notes
Ideas for how to handle config changes:
dbt_valid_to_for_current_records
,dbt_valid_to_current_records
,dbt_valid_to_default
,dbt_valid_to_current_indicator
,dbt_valid_to_current
,dbt_valid_to_current_date
,dbt_valid_to_current_marker
,coalesce_dbt_valid_to
The text was updated successfully, but these errors were encountered: