Skip to main content

about this

this is the database representation of the current model. It is useful when:

this is a Relation, and as such, properties such as {{ this.database }} and {{ this.schema }} compile as expected.

  • Note — Prior to dbt v1.6, the dbt Cloud IDE returns request as the result of {{ ref.identifier }}.

this can be thought of as equivalent to ref('<the_current_model>'), and is a neat way to avoid circular dependencies.

Examples

In older versions of dbt, the most common use of post-hook was to execute grant statements, to apply database permissions to models right after creating them. We recommend using the grants resource config instead, in order to automatically apply grants when your dbt model runs.

Configuring incremental models

models/stg_events.sql
{{ config(materialized='incremental') }}

select
*,
my_slow_function(my_column)

from raw_app_data.events

{% if is_incremental() %}
where event_time > (select max(event_time) from {{ this }})
{% endif %}
0