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

Use column.comment from catalog/database if column.description is missing #263

Closed

Conversation

halvorlu
Copy link
Contributor

Partially resolves #128 (see below)

Description

This will display the column description fetched from the database if there is no column description in the DBT config.
Partially resolves #128, partially because the table description is still missing.
Adding the table description would require more substantial changes, since the table description (as far as I could tell) is not found in catalog.json at the moment.

Checklist

  • I have signed the CLA
  • I have generated docs locally, and this change appears to resolve the stated issue
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

…sing

This will display the column description fetched from the database if there is no column description in the DBT config.
Partially fixes dbt-labs#128, partially because the table description is still missing.
Adding the table description would require more substantial changes, since the table description (as far as I could tell) is not found in catalog.json at the moment.
@cla-bot cla-bot bot added the cla:yes label Apr 11, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
@emmyoop
Copy link
Member

emmyoop commented Apr 25, 2022

@halvorlu thank you so much for this contribution! A lot has changed since the creation of the original issue, but this is still something that could be valuable to dbt-docs!

The table description is actually included in the catalog.

https://github.com/dbt-labs/dbt-core/blob/7d0fccd63f0a50e6f8b1130206118d1fcc19b2ae/schemas/dbt/catalog/v1.json#L144-L153

The above is from the catalog schema. Depending on the adapter/database being used, it may not be consistent but it should be there.

For example, in postgres, we're grabbing the table-level comment here. I'm not sure which adapter you're using but that could be why you may not see the the value coming back in the catalog. It's definitely worth checking that the field is there, even if it is null.

Would you be able to add the table description in to your PR as well?

We don't merge description and comment, we choose the first one that isn't empty/null.
This allows us to display the description found in the database if we haven't entered a description in the dbt config.
@halvorlu
Copy link
Contributor Author

@emmyoop Thanks for useful feedback!

I wasn't aware that the table description was in the catalog. I think the BigQuery adapter (which I use) doesn't fetch it from the database. Anyway, I fixed the code so that we use the comment from the catalog if it is present.

@halvorlu
Copy link
Contributor Author

Should I/we document somewhere that the descriptions are fetched from the database if not provided in the dbt config? This behavior is probably not obvious to most users.

@halvorlu
Copy link
Contributor Author

halvorlu commented May 9, 2022

@emmyoop Anything more that needs to be done in this PR before merging?

@emmyoop
Copy link
Member

emmyoop commented May 17, 2022

We should definitely add some documentation around this functionality. Good call bringing it up! We plan to release this feature with our next minor release, 1.2.0. Can you open up an issue over in docs.dbt.com to add documentation to the docs page.

Copy link
Member

@emmyoop emmyoop left a comment

Choose a reason for hiding this comment

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

@halvorlu thanks for your patience in getting back to you on this!

I looked over the code and it's generally looking good. However, it's applying the override to the column descriptions everywhere (models, seeds, snapshots, sources) but the table override is only happening for sources. It's important this be consistent and predictable.
Since sources are the only object that dbt does not generate/own, it's the only object we want to override.

Can you please update the code so that column comments are only used for sources?

@jtcohen6 jtcohen6 added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Jun 29, 2022
@github-actions
Copy link
Contributor

This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

Although we are closing this PR as stale, it can still be reopened to continue development. Just add a comment to notify the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import missing source descriptions in documentation (table and columns) from catalog
3 participants