You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a model is materialized as a view in snowflake and persist_docs for that model is true, descriptions for that model and that model's columns are persisted in Snowflake as view and column comments.
Describe alternatives you've considered
None
Additional context
I believe there was a time when Views in Snowflake did not support commenting (or their columns didn't?), but a dbt Cloud client mentioned to me that Snowflake does now support this and asked that we look into supporting this functionality. Also I think it's a good idea.
Who will this benefit?
Snowflake users that leverage persist_docs and have views in their projects.
Are you interested in contributing this feature?
Yes!!! I'm guessing we have a check somewhere in the persist_docs handler that just doesn't attempt to alter the view to avoid errors and we can just remove that check for Snowflake.
The text was updated successfully, but these errors were encountered:
@randypitcherii Thanks for opening! dbt has always supported persisting model-column descriptions for Snowflake views, but it historically did not support persisting column-level descriptions, because Snowflake requires column comments to be included in the initial create or replace view statement.
The good news is: We added support for this, as a last-minute addition, in dbt-snowflake==1.0.0! (#53) The way we did it was a bit unorthodox:
Run the model SQL with limit 0 where false, just to get column names and types
Combine those columns with provided descriptions (from .yml file) to template out create or replace view
Try it out:
version: 2models:
- name: my_cool_view_modeldescription: this is a cool modelconfig:
materialized: viewpersist_docs:
relation: truecolumns: truecolumns:
- name: IDdescription: this is a cool column
dbt will compile and run three bits of SQL:
select*from (
select1as id
) as __dbt_sbq
where false
limit0
;
create or replaceviewanalytics.dbt_jcohen.my_cool_view_model
(
ID COMMENT $$this is a cool column$$
)
as (
select1as id
);
comment on view analytics.dbt_jcohen.my_model IS $$this is a cool model$$;
With this result:
While testing, I did realize that the column name checker is case-sensitive, because we didn't do the logic here quite right:
Snowflake columns are almost always uppercase! So this should really be column_name|lower in model_columns. I'm going to open a new bug / good first issue to set that straight.
Describe the feature
When a model is materialized as a view in snowflake and persist_docs for that model is true, descriptions for that model and that model's columns are persisted in Snowflake as view and column comments.
Describe alternatives you've considered
None
Additional context
I believe there was a time when Views in Snowflake did not support commenting (or their columns didn't?), but a dbt Cloud client mentioned to me that Snowflake does now support this and asked that we look into supporting this functionality. Also I think it's a good idea.
Who will this benefit?
Snowflake users that leverage persist_docs and have views in their projects.
Are you interested in contributing this feature?
Yes!!! I'm guessing we have a check somewhere in the
persist_docs
handler that just doesn't attempt to alter the view to avoid errors and we can just remove that check for Snowflake.The text was updated successfully, but these errors were encountered: