[Feature] Accept `None` as a default in `env_var`
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
`env_var` does not recognize `None` or `none` as a default.
If the environment variable is not defined I see ```Parsing Error
Env var required but not provided: '{ENV_VAR}'```
I also tried `env_var('NAMESPACE',none) | as_native` and `env_var('NAMESPACE','none') | as_native` and `env_var('NAMESPACE','')|as_native`
### Expected Behavior
```
{% macro namespaced(prefix) -%}
{%- set _namespace = env_var('NAMESPACE',none) %}
{%- if _namespace is none %}
{{ prefix }}
{%- else -%}
{{ prefix }}_{{ _namespace | trim }}
{%- endif -%}
{%- endmacro %}
```
In the macro above I would like to set `_namespace` to `none` and check `if _namespace is none`.
I have another macro that uses `var()` and this works as expected.
### Steps To Reproduce
Set up a macro that access an env_var that does not exist then call that macro from a model, for example as part of `{{ config(alias=namespaced("MY_TABLE")) }}`
### Relevant log output
_No response_
### Environment
```markdown
- OS: macos 14.5 (intel)
- Python: Python 3.10.14
- dbt --version
Core:
- installed: 1.8.4
- latest: 1.8.4 - Up to date!
Plugins:
- bigquery: 1.8.2 - Up to date!
```
### Which database adapter are you using with dbt?
bigquery
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.