question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support persist_docs for column descriptions

See original GitHub issue

dbt 0.17.0 adds support for persist_docs = {'columns': true} on all core adapters.

In Apache Spark, column-level comments are only supported during table creation with a full column specification. I think that adding column comments as an alter table command may only be possible for Delta tables.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
cristianoperezcommented, May 25, 2021

I changed the syntax from ALTER COLUMN to CHANGE COLUMN and it’s now working. I ran that against 100+ models, around 10 times and no exception

{% macro set_column_description(relation, column_dict) %}  
  {% for column_name in column_dict %}    
    {% set comment = column_dict[column_name]['description'] %}    
    {% set comment_query %}        
      ALTER TABLE {{ relation }} CHANGE COLUMN {{ adapter.quote(column_name) if column_dict[column_name]['quote'] else column_name }} COMMENT '{{ comment }}';      
    {% endset %}      
    {% do run_query(comment_query) %}    
  {% endfor %}
{% endmacro %}
0reactions
cristianoperezcommented, May 25, 2021

I changed the syntax from ALTER COLUMN to CHANGE COLUMN and it’s now working.

Genius! From the docs, it sure sounds like these are meant to be interchangeable…

Would you be up to open a PR to add spark__alter_column_comment by way of alter table change column?

I will

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support persist_docs for column descriptions · Issue #84 · dbt ...
In Apache Spark, column-level comments are only supported during table creation with a full column specification. I think that adding column ...
Read more >
persist_docs | dbt Developer Hub
Optionally persist resource descriptions as column and relation comments in the database. By default, documentation persistence is disabled, ...
Read more >
How to persist column descriptions in BigQuery tables
1 Answer 1 · Sources unsupported persist_docs -> sources tab · External Tables unsupported (Can't find in docs again but read today in...
Read more >
Captain Obvious' Guide to Column Descriptions - Dataedo Blog
Captain Obvious' Guide to Column Descriptions - Data Dictionary Best Practices ... Some may think that table and column names are enough.
Read more >
Can Looker import descriptions from Snowflake?
I'm using dbt to push descriptions to Snowflake using the persist docs functionality. I am now wondering if Looker can import the Snowflake ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found