Skip to main content
💡Did you know...
Available from dbt v1.12 or with the dbt "Latest" release track.

latest_version_pointer Beta

dbt_project.yml
models:
<resource-path>:
+latest_version_pointer:
enabled: true | false
alias: <string>

Definition​

Beta feature

The latest_version_pointer config is a beta feature in dbt Core v1.12.

The latest_version_pointer config creates a view named after a versioned model's base name (for example, dim_customers) that always points to the latest versioned relation (for example, dim_customers_v2). The view is created after the model with is_latest_version = true materializes successfully and is skipped for all other versions.

You can also enable this feature globally for all versioned models by setting the latest_version_pointer_enabled_by_default flag to true in dbt_project.yml:

dbt_project.yml
flags:
latest_version_pointer_enabled_by_default: true

latest_version_pointer accepts two optional sub-keys for per-model control:

KeyTypeDefaultDescription
enabledboolean—Enables or disables the pointer view for this model. Overrides the latest_version_pointer_enabled_by_default project flag when set; defers to the flag when not set.
aliasstringModel base nameCustom name for the pointer view. Overrides the default base name. For more information, see Alias customization.
Loading table...

Alias customization​

By default, the pointer view uses the model's base name (for example, dim_customers). You can customize this in two ways:

To prevent naming collisions, dbt raises an error if the latest version's alias is the same as the pointer name. For example, the following configuration would cause an error because both dim_customers_v2 and the pointer view would resolve to dim_customers:

models:
- name: dim_customers
versions:
- v: 1
- v: 2
config:
alias: dim_customers # collides with the pointer view name
config:
latest_version_pointer:
enabled: true

To fix this, select one of the following options:

Remove the alias from the latest version and let the automatic pointer handle it:

config:
alias: dim_customers

Disable the latest version pointer for that model​

This approach is immediately backward-compatible for pre-existing alias configs:

        config:
alias: dim_customers
config:
latest_version_pointer:
enabled: false

Set a unique alias​

        config:
alias: dim_customers_latest

Override the generate_latest_version_pointer_alias macro​

Override the generate_latest_version_pointer_alias macro to use a different naming convention globally:

macros/generate_latest_version_pointer_alias.sql
{% macro generate_latest_version_pointer_alias(custom_alias_name=none, node=none) -%}
{{ node.name ~ "_latest" }}
{%- endmacro %}

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

0
Loading