-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #2711
Changes from 7 commits
81ab946
6e06bd0
099fea8
108d843
7aa8030
25a869a
955f4ae
a8d6691
eb35794
671a29f
76aa8c7
47ab741
3834805
af118bc
2562deb
b4a2ed6
c28ffcd
55813d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select 1 as id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""""Test adapter specific config options.""" | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
import textwrap | ||
import yaml | ||
|
||
|
||
class TestBigqueryDatePartitioning(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "bigquery_test_022" | ||
|
||
@property | ||
def models(self): | ||
return "adapter-specific-models" | ||
|
||
@property | ||
def profile_config(self): | ||
return self.bigquery_profile() | ||
|
||
@property | ||
def project_config(self): | ||
return yaml.safe_load(textwrap.dedent('''\ | ||
config-version: 2 | ||
models: | ||
test: | ||
materialized: table | ||
expiring_table: | ||
time_to_expiration: 4 | ||
''')) | ||
|
||
@use_profile('bigquery') | ||
def test_time_to_expiration(self): | ||
_, stdout = self.run_dbt_and_capture() | ||
self.assertIn( | ||
'expiration_timestamp: TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL ' | ||
'4 hour)', stdout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the example I copied here was one that expected failure on the model, so the query would be dumped in I probably want to inspect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want Also, don't feel at all obligated to do this, but because we use pytest for tests now you are free to use the (much more ergonomic, at least to me) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beckjake The error I got makes me think
This config adds the expiration_timestamp as part of the ddl, and if this was ddl, it should say something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, now that I look at this more carefully, I think this will be in the output if you run with It is, I suppose, always possible that we don't log all our queries on bigquery? That would be pretty bad behavior on our part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran this on a real project locally and it doesn't look like the ddl is anywhere in run_results.json, but it definitely is in the output with |
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.
The name 'time_to_expiration' doesn't provide any hints about the unit. Maybe this could be 'hours_to_expiration'?
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.
@jtcohen6 How do you feel about this, following #2697?
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.
I'm totally in favor of
hours_to_expiration