From 713e781473f7c3b74b3d59d7a46419dc36a85841 Mon Sep 17 00:00:00 2001 From: Alexander Kutz Date: Tue, 22 Sep 2020 14:54:56 -0500 Subject: [PATCH 1/4] Reset branch against dev/0.8.1 and re-added changes. udpated changelog.md --- CHANGELOG.md | 6 ++++++ plugins/snowflake/dbt/include/snowflake/macros/catalog.sql | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d93aa0f7c..f67d802b2e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## dbt 0.18.1 (Release TBD) +### Feature +- Added 'Last Modified' stat in snowflake catalog macro. Now should be available in docs. ([#2728](https://github.com/fishtown-analytics/dbt/issues/2728)) + +Contributors: +- [@Mr-Nobody99](https://github.com/Mr-Nobody99) ([#2732](https://github.com/fishtown-analytics/dbt/pull/2732)) + ## dbt 0.18.1b2 (September 22, 2020) diff --git a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql index e87bc615468..888da94b129 100644 --- a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql +++ b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql @@ -27,6 +27,11 @@ 'Approximate size of the table as reported by Snowflake' as "stats:bytes:description", (bytes is not null) as "stats:bytes:include" + 'Last Modified' as "stats:last_modified:label", + to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value", + 'The timestamp for last update/change' as "stats:last_modified:description", + (last_altered is not null and table_type='BASE_TABLE') as "stats:last_modified:include" + from {{ information_schema }}.tables ), From 8cf9311cedefcfa270b78fd8c7efcb0aaecb0fd1 Mon Sep 17 00:00:00 2001 From: Alexander Kutz Date: Tue, 22 Sep 2020 16:04:30 -0500 Subject: [PATCH 2/4] Changed 'BASE_TABLE' to 'BASE TABLE' --- plugins/snowflake/dbt/include/snowflake/macros/catalog.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql index 888da94b129..fded1d48062 100644 --- a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql +++ b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql @@ -30,7 +30,7 @@ 'Last Modified' as "stats:last_modified:label", to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value", 'The timestamp for last update/change' as "stats:last_modified:description", - (last_altered is not null and table_type='BASE_TABLE') as "stats:last_modified:include" + (last_altered is not null and table_type='BASE TABLE') as "stats:last_modified:include" from {{ information_schema }}.tables From a93e288d6a54d32201b2b701af7472246f6b42c4 Mon Sep 17 00:00:00 2001 From: Alexander Kutz Date: Tue, 22 Sep 2020 17:48:48 -0500 Subject: [PATCH 3/4] Added missing commaabove addition. --- plugins/snowflake/dbt/include/snowflake/macros/catalog.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql index fded1d48062..51dedc2683c 100644 --- a/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql +++ b/plugins/snowflake/dbt/include/snowflake/macros/catalog.sql @@ -25,7 +25,7 @@ 'Approximate Size' as "stats:bytes:label", bytes as "stats:bytes:value", 'Approximate size of the table as reported by Snowflake' as "stats:bytes:description", - (bytes is not null) as "stats:bytes:include" + (bytes is not null) as "stats:bytes:include", 'Last Modified' as "stats:last_modified:label", to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value", From e3f557406feffee69e32aa58c3d549ff9b00e176 Mon Sep 17 00:00:00 2001 From: Alexander Kutz Date: Wed, 23 Sep 2020 11:08:08 -0500 Subject: [PATCH 4/4] Updated test/integration/029_docs_generate_test.py to reflect new stat --- .../029_docs_generate_tests/test_docs_generate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/029_docs_generate_tests/test_docs_generate.py b/test/integration/029_docs_generate_tests/test_docs_generate.py index 397dd3737bc..f4a89db5a91 100644 --- a/test/integration/029_docs_generate_tests/test_docs_generate.py +++ b/test/integration/029_docs_generate_tests/test_docs_generate.py @@ -266,13 +266,20 @@ def _snowflake_stats(self): 'description': 'Approximate size of the table as reported by Snowflake', 'include': True, }, + 'last_modified': { + 'id': 'last_modified', + 'label': 'Last Modified', + 'value': AnyString(), + 'description': 'The timestamp for last update/change', + 'include': True, + }, 'row_count': { 'id': 'row_count', 'label': 'Row Count', 'value': 1.0, 'description': 'An approximate count of rows in this table', 'include': True, - }, + } } def _bigquery_stats(self, is_table, partition=None, cluster=None):