Skip to content

Commit

Permalink
Merge pull request #2732 from Mr-Nobody99/feature/add-snowflake-last-…
Browse files Browse the repository at this point in the history
…modified

Added last_altered query to Snowflake catalog macro
  • Loading branch information
jtcohen6 authored Sep 24, 2020
2 parents e265ab6 + e3f5574 commit cb0e625
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:/fishtown-analytics/dbt/issues/2728))

Contributors:
- [@Mr-Nobody99](https:/Mr-Nobody99) ([#2732](https:/fishtown-analytics/dbt/pull/2732))

## dbt 0.18.1b2 (September 22, 2020)


Expand Down
7 changes: 6 additions & 1 deletion plugins/snowflake/dbt/include/snowflake/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
'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",
'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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cb0e625

Please sign in to comment.