using `{{ ref('anything') }}` in a `set_sql_header` call resolves to the current model and not 'anything'
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Describe the bug
Here's a minimal reproducible example (running on BigQuery).
```sql
-- test_tmp_1.sql
{{
config(materialized="table")
}}
select a.* from unnest([
struct(1 as key, 1 as value)
]) as a
```
```sql
-- test_tmp_2.sql
{{
config(materialized="table")
}}
{% call set_sql_header(config) %}
select * from {{ ref('test_tmp_1') }};
{% endcall %}
select * from {{ ref('test_tmp_1') }}
```
When I `dbt run` this project, I get an error when `test_tmp_2` is run saying something along the lines of "test_tmp_2 does not exist".
The output SQL for `test_tmp_2` after a `dbt run` shows:
```sql
select * from `project`.`dataset`.`test_tmp_2`;
create or replace table `project`.`dataset`.`test_tmp_2`
OPTIONS()
as (
select * from `project`.`dataset`.`test_tmp_1`
);
```
### Expected behavior
The `ref('test_tmp_1')` call in the `call set_sql_header(config)` block should resolve to `test_tmp_1`.
Instead it resolves to `test_tmp_2`.
### System information
**Which database are you using dbt with?**
- [ ] postgres
- [ ] redshift
- [x] bigquery
- [ ] snowflake
- [ ] other (specify: ____________)
**The output of `dbt --version`:**
```
installed version: 0.18.0
latest version: 0.18.0
Up to date!
Plugins:
- bigquery: 0.18.0
- snowflake: 0.18.0
- redshift: 0.18.0
- postgres: 0.18.0
```
**The operating system you're using:**
macOS 10.15.6
**The output of `python --version`:**
Python 3.8.1
### Additional context
N/A
Contributor guide
Assessment
This issue has not been assessed yet.