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

Support for persist_docs #77

Merged
merged 4 commits into from
Aug 17, 2022
Merged

Support for persist_docs #77

merged 4 commits into from
Aug 17, 2022

Conversation

hovaesco
Copy link
Member

Overview

Checklist

  • This PR includes tests, or tests are not required/relevant for this PR
  • README.md updated and added information about my change
  • CHANGELOG.md updated and added information about my change

@hovaesco hovaesco mentioned this pull request Aug 1, 2022
3 tasks
@hovaesco hovaesco force-pushed the hovaesco/persist-docs branch 3 times, most recently from 38ed99d to 8793b42 Compare August 12, 2022 10:01
@hovaesco hovaesco marked this pull request as ready for review August 12, 2022 10:01
@hovaesco hovaesco changed the title WIP - Support for persist_docs Support for persist_docs Aug 12, 2022
@hovaesco hovaesco requested review from mdesmet and findinpath and removed request for mdesmet August 12, 2022 10:08
{% macro trino__alter_relation_comment(relation, relation_comment) -%}
comment on {{ relation.type }} {{ relation }} IS '{{ relation_comment | replace("'", "''") }}';
{% endmacro %}

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove one line

Copy link
Member Author

Choose a reason for hiding this comment

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

Two new lines are present after each macro in this file.

dbt/adapters/trino/connections.py Outdated Show resolved Hide resolved

{% macro trino__alter_column_comment(relation, column_dict) %}
{% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute="name") | list %}
{% for column_name in column_dict if (column_name in existing_columns) %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we supposed to remove column comments as well when they are not set anymore?
same question for tables.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comments are deleted if there are no set anymore. It's done by setting an empty comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

The removal of comments is done by the command

COMMENT ON TABLE/COLUMN ... IS NULL

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, the code adjusted accordingly to the comment.

tests/functional/adapter/persist_docs/fixtures.py Outdated Show resolved Hide resolved
"name": "persist_docs_tests",
"models": {
"+persist_docs": {
"relation": True
Copy link
Collaborator

Choose a reason for hiding this comment

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

we basically test whether dbt is persisting docs for relations and columns, but can we check whether the comments were set as expected on the underlying database?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for a valid comment. This test should be handled by macro https://github.com/starburstdata/dbt-trino/blob/master/dbt/include/trino/macros/catalog.sql which creates a file target/catalog.json generated by dbt docs generate command.

In the get_catalog macro table and column comments are returned as null. Information schema tables in Trino miss comment columns. I will create a follow-up ticket in Trino for it.

Docs are generated by a file located in target/manifest.json and all comments are present in dbt-docs and persisted in the Trino.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@mdesmet mdesmet left a comment

Choose a reason for hiding this comment

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

LGTM

Maybe add a TODO in the code in the metadata query for the comments with a link to the Trino issue.

@hovaesco hovaesco merged commit 0dad053 into master Aug 17, 2022
@hovaesco hovaesco mentioned this pull request Aug 17, 2022
@mdesmet mdesmet deleted the hovaesco/persist-docs branch March 10, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants