[Bug] Macro adapter.get_columns_in_relation() doesn't return any columns during unit testing
DmytroSly opened this issue · 4 comments
Is this a new bug in dbt-core?
- I believe this is a new bug in dbt-core
- 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
- 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.
FYI
I tried using the override functionality to set the list of columns to be returned by the macro adapter.get_columns_in_relation()
, but the problem with the override in my case is that this macro is used two times, and each time for a different model. A different list of columns should be returned for every model, but the override makes it return the same list of columns for different models.