dbt-labs / dbt-postgres

Apache License 2.0
22 stars 12 forks source link

Support persisting docs for `materialized_view` materializations #98

Closed morsapaes closed 2 months ago

morsapaes commented 4 months ago

The macro that backs object-level persist_docs uses {{ relation.type }} to derive the object type in the COMMENT ON statement. This breaks for materialized_view materializations:

15:35:01  Database Error in model funds_movement (models/marts/funds_movement.sql)
15:35:01    Expected one of TABLE or VIEW or COLUMN or MATERIALIZED or SOURCE or SINK or INDEX or FUNCTION or CONNECTION or TYPE or SECRET or ROLE or DATABASE or SCHEMA or CLUSTER, found identifier "materialized_view"
15:35:01    LINE 5:   comment on materialized_view "marta"."public"."funds_moveme...
15:35:01                         ^
15:35:01    compiled Code at target/run/mz_get_started/models/marts/funds_movement.sql
15:35:01
15:35:01  Done. PASS=3 WARN=0 ERROR=2 SKIP=0 TOTAL=5

We've fixed this a while back for dbt-materialize (which shims dbt-postgres) in Materialize #21878, but it really should be fixed at the source!


Fixes #120, fixes #11.

cla-bot[bot] commented 4 months ago

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @morsapaes

morsapaes commented 4 months ago

Signed the CLA, but...not sure if some manual steps are needed to thread that through?

morsapaes commented 2 months ago

Does this proposal fix both a postgres issue and materialize issue?

It fixes a dbt-postgres issue that is inherited by our adapter (and others shimming dbt-postgres). We put up a patch a while back in dbt-materialize (Materialize #21878), since it was blocking our users.

Two things. Can you: make a changelog entry with changie (docs)? Integration tests are blocked for that reason open (or link to) an issue on this repo? This is just for tracking purposes?

Opened #120 for tracking purposes, and marked this PR as fixing it. Will push a changelog entry shortly, too.

Thanks, @dataders!

mikealfare commented 2 months ago

Thanks for the contribution @morsapaes! Do you mind adding a test case for this? We want to at least make sure that a user can submit a materialized view model with a description. Bonus points for verifying that the materialized view has the expected comment.

morsapaes commented 2 months ago

I will as soon as I have some bandwidth this week, @mikealfare.

colin-rogers-dbt commented 2 months ago

@morsapaes took a quick pass at some tests, we can open an issue to expand out base adapter persist docs tests to cover materialized views