Skip to content
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

Allow enabling/disabling stats collection on catalog table using env var #1048

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240516-224134.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Allow enabling/disabling stats collection on catalog table using env var
time: 2024-05-16T22:41:34.256095+01:00
custom:
Author: aranke
Issue: "1048"
11 changes: 7 additions & 4 deletions dbt/include/snowflake/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@


{% macro snowflake__get_catalog_tables_sql(information_schema) -%}
{%- set enable_stats = env_var('DBT_CATALOG_TABLE_ENABLE_STATS', 'true') == 'true' -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there precedent for using an env_var this way in macros? I suspect the Adapters team might want us to have an official flag for this.


select
table_catalog as "table_database",
table_schema as "table_schema",
Expand All @@ -46,11 +48,10 @@
else table_type
end as "table_type",
comment as "table_comment",
table_owner as "table_owner"

-- note: this is the _role_ that owns the table
table_owner as "table_owner",

'Clustering Key' as "stats:clustering_key:label",
{%- if enable_stats %}
,'Clustering Key' as "stats:clustering_key:label",
clustering_key as "stats:clustering_key:value",
'The key used to cluster this table' as "stats:clustering_key:description",
(clustering_key is not null) as "stats:clustering_key:include",
Expand All @@ -69,6 +70,8 @@
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"
{%- endif %}

from {{ information_schema }}.tables
{%- endmacro %}

Expand Down
Loading