Skip to content

Commit

Permalink
hours_to_expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
kconvey committed Aug 19, 2020
1 parent c28ffcd commit 55813d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions plugins/bigquery/dbt/adapters/bigquery/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BigqueryConfig(AdapterConfig):
labels: Optional[Dict[str, str]] = None
partitions: Optional[List[str]] = None
grant_access_to: Optional[List[Dict[str, str]]] = None
time_to_expiration: Optional[int] = None
hours_to_expiration: Optional[int] = None


class BigQueryAdapter(BaseAdapter):
Expand Down Expand Up @@ -746,10 +746,10 @@ def get_table_options(
expiration = 'TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 12 hour)'
opts['expiration_timestamp'] = expiration

if (config.get('time_to_expiration') is not None) and (not temporary):
if (config.get('hours_to_expiration') is not None) and (not temporary):
expiration = (
'TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL '
'{} hour)').format(config.get('time_to_expiration'))
'{} hour)').format(config.get('hours_to_expiration'))
opts['expiration_timestamp'] = expiration

if config.persist_relation_docs() and 'description' in node:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def project_config(self):
test:
materialized: table
expiring_table:
time_to_expiration: 4
hours_to_expiration: 4
'''))

@use_profile('bigquery')
def test_bigquery_time_to_expiration(self):
def test_bigquery_hours_to_expiration(self):
_, stdout = self.run_dbt_and_capture(['--debug', 'run'])

self.assertIn(
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_bigquery_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ def test_parse_partition_by(self):
}
)

def test_time_to_expiration(self):
def test_hours_to_expiration(self):
adapter = self.get_adapter('oauth')
mock_config = create_autospec(
dbt.context.providers.RuntimeConfigObject)
config = {'time_to_expiration': 4}
config = {'hours_to_expiration': 4}
mock_config.get.side_effect = lambda name: config.get(name)

expected = {
Expand All @@ -585,11 +585,11 @@ def test_time_to_expiration(self):
self.assertEqual(expected, actual)


def test_time_to_expiration_temporary(self):
def test_hours_to_expiration_temporary(self):
adapter = self.get_adapter('oauth')
mock_config = create_autospec(
dbt.context.providers.RuntimeConfigObject)
config={'time_to_expiration': 4}
config={'hours_to_expiration': 4}
mock_config.get.side_effect = lambda name: config.get(name)

expected = {
Expand Down

0 comments on commit 55813d9

Please sign in to comment.