target
target
contains information about your connection to the warehouse.
- dbt CLI: These values are based on the target defined in your
profiles.yml
file - dbt Cloud Scheduler:
target.name
is defined per job as described here.- For all other attributes, the values are defined by the deployment connection. To check any of these values, head to
Environments
(via the hamburger menu), select the relevant deployment environment, and select settings.
- dbt Cloud IDE: The values are defined by your connection and credentials. To check any of these values, head to your account (via your profile image in the top right hand corner), and select the project under "Credentials".
Some configs are shared between all adapters, while others are adapter-specific.
Common
Variable | Example | Description |
---|---|---|
target.profile_name | jaffle_shop | The name of the active profile |
target.name | dev | Name of the active target |
target.schema | dbt_alice | Name of the dbt schema (or, dataset on BigQuery) |
target.type | postgres | The active adapter being used. One of "postgres", "snowflake", "bigquery", "redshift" |
target.threads | 4 | The number of threads in use by dbt |
Adapter-specific
Snowflake
Variable | Example | Description |
---|---|---|
target.database | RAW | Database name specified in active target. |
target.warehouse | TRANSFORM | Name of the Snowflake virtual warehouse |
target.user | TRANSFORM_USER | The user specified in the active target |
target.role | TRANSFORM_ROLE | The role specified in the active target |
target.account | abc123 | The account specified in the active target |
Postgres/Redshift
Variable | Example | Description |
---|---|---|
target.dbname | analytics | Database name specified in active target. |
target.host | abc123.us-west-2.redshift.amazonaws.com | The host specified in active target |
target.user | dbt_user | The user specified in the active target |
target.port | 5439 | The port specified in the active profile |
BigQuery
Variable | Example | Description |
---|---|---|
target.project | abc-123 | The project specified in the active profile |
target.dataset | dbt_alice | The dataset the active profile |
Examples
target.name
to limit data in dev
Use As long as you use sensible target names, you can perform conditional logic to limit data when working in dev.
select*from source('web_events', 'page_views'){% if target.name == 'dev' %}where created_at >= dateadd('day', -3, current_date){% endif %}
target.name
to change your source database
Use If you have specific Snowflake databases configured for your dev/qa/prod environments, you can set up your sources to compile to different databases depending on your environment.
version: 2sources:- name: source_namedatabase: |{%- if target.name == "dev" -%} raw_dev{%- elif target.name == "qa" -%} raw_qa{%- elif target.name == "prod" -%} raw_prod{%- else -%} invalid_database{%- endif -%}schema: source_schema