Skip to content

Commit

Permalink
Explain behavior of config.get
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Dec 6, 2024
1 parent 2c538a6 commit 1f60997
Showing 1 changed file with 9 additions and 1 deletion.
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 it not `None`
1. The configuration variable exists, it it is `None`

Check warning on line 39 in website/docs/reference/dbt-jinja-functions/config.md

View workflow job for this annotation

GitHub Actions / vale

[vale] website/docs/reference/dbt-jinja-functions/config.md#L39

[custom.Repitition] 'it' is repeated!
Raw output
{"message": "[custom.Repitition] 'it' is repeated!", "location": {"path": "website/docs/reference/dbt-jinja-functions/config.md", "range": {"start": {"line": 39, "column": 39}}}, "severity": "WARNING"}
1. The configuration variable does not exist

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

0 comments on commit 1f60997

Please sign in to comment.