Skip to content

[CT-2468] [Feature] For versioned models, automatically create view/clone of latest version in unsuffixed database location #7442

@jtcohen6

Description

@jtcohen6

Thanks @dbeatty10 @joellabes for working through this with me!

As the producer of a versioned model, I want the unsuffixed database relation (<db>.<schema>.<model_name>) to always point to the latest version of that model. This provides downstream consumers with the same optionality that's available to ref: "pin" to a specific version (suffix), or "unpin" (no suffix) and always get the latest.

dbt should handle this for me, by creating an additional "pointer" view (select * from <latest>) or table clone (depending on the relation type and data platform support) whenever I run the latest version of my model.

Implementation options

I'm not in love with any of these options:

  1. Create a new node in the manifest with this logic, materialized as a view (or clone?). Not sure if/how we'd be able to set configurations on that additional node/object (e.g. persisting descriptions).
  2. Update the view, table, and incremental materializations to produce an additional relation, if the model is versioned (and this is the latest version)
  3. Provide users with a macro that they can "set and forget" as a model post-hook

Of those, (3) is the least magical, and it's what we'll propose to users in the short term (v1.5). We still don't like:

  • Hooks in general, and especially hooks that run DDL to create database objects
  • Lacking the robustness of an actual materialization
  • Requiring users to copy-paste a macro and update their project, when this is the Right Behavior that should just happen out of the box
  • Making the proposed logic for schema management more complicated

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions