-
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
Support TTL for BigQuery tables #2697
Comments
@kconvey Thanks for the writeup! I'm supportive of adding this as a model config. What do you think about As you rightly observe, we already sort of have it, in that temporary tables are actually non-temporary tables with an arbitrary 12-hour TTL. I'd actually like to change that, and to use real temporary tables (i.e. BigQuery scripts) wherever we currently use 12-hours-to-live tables. We tried to do it in #2140, but we found we would have needed to rework snapshots in a way that was out of scope. It's definitely out of scope for this feature, too, but it's still on my mind :) |
Planning to create the PR for this pretty soon, but I'm curious how you feel about adding support in |
That's a good use case. I'd be more inclined to support it, still with models:
+time_to_expiration: "{{ ('8' if target.name == 'dev' else '1000') | as_number }}" I think configs belong in
|
Wasn't sure if that context was available in |
Yes, good call to include some kind of truthy condition. I think you could get the code above to return models:
+time_to_expiration: "{{ ('8' if target.name == 'dev' else 'none') | as_native }}" Better safe than sorry, though. |
Describe the feature
Add a BigQuery adapter specific config option
ttl
(or similar name) which denotes how long the produced table will exist, before being cleaned up automatically by BigQuery. This will take advantage of theexpiration_timestamp
and the BQ functionsTIMESTAMP_ADD()
CURRENT_TIMESTAMP()
, andINTERVAL
(withttl
as an argument)Describe alternatives you've considered
Do this as a post-processing step
Configuring a model's TTL #1472 was the idea of having dbt keep track of how long models have existed, and only update once expired, and called itself
TTL
, but is pretty different than this proposal.Additional context
AFAIK this is a BigQuery only feature (did some brief googling around and didn't find anything). This feature is already used for
temporary
tables in the BQ adapter, which are somewhat arbitrarily set to 12 hour TTLs. The same feature is not used for the other support databases, which have aTEMPORARY
option which deletes tables at the end of a session, instead.Who will this benefit?
Are you interested in contributing this feature?
This can be upstreamed from a locally maintained fork without too many changes (so definitely).
The text was updated successfully, but these errors were encountered: