From 55813d920900a15a3b963d3f71335b2fd0bc1f2f Mon Sep 17 00:00:00 2001 From: Kurt Convey Date: Wed, 19 Aug 2020 10:08:52 -0600 Subject: [PATCH] hours_to_expiration --- plugins/bigquery/dbt/adapters/bigquery/impl.py | 6 +++--- .../022_bigquery_test/test_bigquery_adapter_specific.py | 4 ++-- test/unit/test_bigquery_adapter.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/bigquery/dbt/adapters/bigquery/impl.py b/plugins/bigquery/dbt/adapters/bigquery/impl.py index 9dddd52bf30..cbd4bd6b69f 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/impl.py +++ b/plugins/bigquery/dbt/adapters/bigquery/impl.py @@ -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): @@ -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: diff --git a/test/integration/022_bigquery_test/test_bigquery_adapter_specific.py b/test/integration/022_bigquery_test/test_bigquery_adapter_specific.py index 3a37fa4ac42..dcb8cf4a56b 100644 --- a/test/integration/022_bigquery_test/test_bigquery_adapter_specific.py +++ b/test/integration/022_bigquery_test/test_bigquery_adapter_specific.py @@ -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( diff --git a/test/unit/test_bigquery_adapter.py b/test/unit/test_bigquery_adapter.py index 048d78fa6c8..837283b3107 100644 --- a/test/unit/test_bigquery_adapter.py +++ b/test/unit/test_bigquery_adapter.py @@ -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 = { @@ -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 = {