[Enhancement] Enable `adapter.get_columns_in_relation()` macro to return columns during unit testing
- 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
The model I configured a unit test for, relies on the macro adapter.get_columns_in_relation() that I use for one of the models, referenced with the ref() macro. However, the macro adapter.get_columns_in_relation() returns an empty list for a relation during unit testing. This causes the SQL code to compile improperly and fail.
### Expected Behavior
The macro adapter.get_columns_in_relation() should return a list of columns for a referenced relation during unit testing.
### Steps To Reproduce
Create a SQL model that relies on the list of columns returned by the macro adapter.get_columns_in_relation(), then configure and run a unit test for this model
### Relevant log output
_No response_
### Environment
```markdown
- OS: Windows 10 Enterprise
- Python: 3.11.4
- dbt: 1.8.0
```
### Which database adapter are you using with dbt?
snowflake
### Additional Context
I hope it is possible to fix this, since dbt knows for sure the list of columns of all the referenced models. Apart from the input columns provided in the unit test config, dbt injects all other columns with NULL values into the resulting SQL for such a unit test. The input tables for a model, that I am trying to unit test, are really wide - 70-80 columns.
Contributor guide
Assessment
This issue has not been assessed yet.