From 4e19710cbb465221e31db5f1dc81f032b89a2eca Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Fri, 30 Jun 2023 15:21:12 +0200 Subject: [PATCH] Update post-hook for "latest" model version This is still just a placeholder "YMMV" solution until we decide on a real implementation: - https://github.com/dbt-labs/dbt-core/issues/7442 --- website/docs/docs/collaborate/govern/model-versions.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/collaborate/govern/model-versions.md b/website/docs/docs/collaborate/govern/model-versions.md index 9ee9c345d8e..64559aa70af 100644 --- a/website/docs/docs/collaborate/govern/model-versions.md +++ b/website/docs/docs/collaborate/govern/model-versions.md @@ -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