latest_version_pointer Beta
- Project file
- Property file
- SQL config
models:
<resource-path>:
+latest_version_pointer:
enabled: true | false
alias: <string>
models:
- name: [<model-name>]
config:
latest_version_pointer:
enabled: true | false
alias: <string>
{{ config(
latest_version_pointer={
"enabled": true | false,
"alias": "<string>"
}
) }}
Definition​
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:
flags:
latest_version_pointer_enabled_by_default: true
latest_version_pointer accepts two optional sub-keys for per-model control:
| 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:
- Per model: Set
latest_version_pointer.aliasin the model config. - Globally: Override the
generate_latest_version_pointer_aliasmacro in your project. This macro follows the same pattern asgenerate_alias_name.
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(recommended) - Disable the latest version pointer for that model
- Set a unique
alias - Override the
generate_latest_version_pointer_aliasmacro
Remove the alias (recommended)​
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:
{% macro generate_latest_version_pointer_alias(custom_alias_name=none, node=none) -%}
{{ node.name ~ "_latest" }}
{%- endmacro %}
Related documentation​
- Model versions
- Pointing to the latest version
latest_version_pointer_enabled_by_defaultflagversionslatest_version
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.