Skip to content

Commit

Permalink
Update post-hook for "latest" model version (#3652)
Browse files Browse the repository at this point in the history
This is still just a placeholder "YMMV" solution until we decide on a
real implementation:
- dbt-labs/dbt-core#7442

---

If you're versioning `some_model` for the first time:
- that model is materialized as a `table`
- `my_db.my_schema.some_model` will exist as a table in the database
- needs to be dropped before running `create or replace view`

(NOTE: I need to actually test this code)

Co-authored-by: Joel Labes <[email protected]>
  • Loading branch information
jtcohen6 and joellabes authored Jul 4, 2023
1 parent 72fb469 commit ca60019
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion website/docs/docs/collaborate/govern/model-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,13 @@ We intend to build this into `dbt-core` as out-of-the-box functionality. (Upvote
-- otherwise, it's a no-op
{% if model.get('version') and model.get('version') == model.get('latest_version') %}
{% set new_relation = this.incorporate(path={"identifier": model['name']}) %}
{% set new_relation = this.incorporate(path={"identifier": model['name']}) %}
{% set existing_relation = load_relation(new_relation) %}
{% if existing_relation and not existing_relation.is_view %}
{{ drop_relation_if_exists(existing_relation) }}
{% endif %}
{% set create_view_sql -%}
-- this syntax may vary by data platform
Expand Down

0 comments on commit ca60019

Please sign in to comment.