Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain behavior of config.get #6611

Merged
merged 8 commits into from
Dec 9, 2024
10 changes: 9 additions & 1 deletion website/docs/reference/dbt-jinja-functions/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ __Args__:

The `config.get` function is used to get configurations for a model from the end-user. Configs defined in this way are optional, and a default value can be provided.

There are 3 cases:
1. The configuration variable exists, it is not `None`
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
1. The configuration variable exists, it is `None`
1. The configuration variable does not exist
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

Example usage:
```sql
{% materialization incremental, default -%}
-- Example w/ no default. unique_key will be None if the user does not provide this configuration
{%- set unique_key = config.get('unique_key') -%}

-- Example w/ default value. Default to 'id' if 'unique_key' not provided
-- Example w/ alternate value. Use alternative of 'id' if 'unique_key' config is provided, but it is None
{%- set unique_key = config.get('unique_key') or 'id' -%}

-- Example w/ default value. Default to 'id' if the 'unique_key' config does not exist
{%- set unique_key = config.get('unique_key', default='id') -%}
...
```
Expand Down
Loading