-
Notifications
You must be signed in to change notification settings - Fork 93
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
fix: enable persist_docs for views #337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last time I implemented the feature there was an error when trying to put the comments in the glue view, leading to the view being unusable.
Can you give us a model to reproduce, have you tried to persist the docs ? Run the queries on the view afterwards ?
I'm sorry, you are right. I thought, I tested it enough, but views don't work after creating. |
Current verison of adapter (1.5.0) breaks views when executing persistent_docs because some important fields of Glue Table representing Athena views are missing in source code: https://github.com/dbt-athena/dbt-athena/blob/ff479c147eb922119b774acb42375f924bc968a1/dbt/adapters/athena/impl.py#L647 I fixed updating of Glue table Description taking code from awswrangler library as a reference: Now it works like a charm for tables and views updating Glue Table Description (straightforward way) and custom Parameter called 'comment' (optional, but useful for compatibility with common approach in databases world). Additionally I put some efforts trying optimize creation of new version of Glue Tables during deployment. I think that ideally:
Manual testingViewFirst run of view model: Populated: Table Description, Table 'comment' Property, Column Comment. Only one version of table exists after single dbt run. Deployed view works and it is selectable. Seconf run of view model: One Table Version added. TableWe have two versions from scratch (this is a flaw in table creation process). Incremental tableInitial run: We have two versions right after creation (similar to previous example). Second run (with the same model description in schema.yml): Table description was not updated because there is no need to do it. No new Table Version was produced. Third run (with new model description): We have new Table Version with updated description. ConclusionSuggested fix is simple and it allows to populate model/columns descriptions to Glue Table for Athena views. Tested and verified in my AWS environment. |
Thank you for checking this fix. It will help me to simplify postprocessing of Glue Tables deployed with dbt by custom scheduled script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, a few comments 🔥 👍🏻
@Jrmyy Thanks a lot for your time and comments. I thinks I fixed it all. |
@roslovets great job done with updating table metadata 👍 🌟 🚀 ! Some minor comments, mostly about typing which will make the code more easy to understand. |
Guys, thank you for smart suggestions. It looks beter now. |
Description
Since Athena view is just a Glue table it's an omission that persist_docs feature is disabled for views. It works exactly the same as with Athena tables.
Checklist