-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit test fixture (csv) returns "" for empty value #9881
Comments
Thanks for trying out unit testing and reporting this @leesiongchan ! How dbt seeds treat empty valuesdbt-labs/docs.getdbt.com#4867 describes how dbt seeds handle empty strings by converting them to SQL
It totally makes sense that you'd expect CSV-formatted unit test fixtures to behave the same way as dbt seeds. But we'll need to take another look at this and choose between a couple options for moving forward. Our optionsWhat's your take on this @graciegoheen? We'd need to choose between one of these two options:
To me the 1st option has more congruence and the 2nd option has more dissonance. What do you think, Grace?
|
Hello! @leesiongchan - thanks for opening up this request. I'd like to know more about your use case here. We've designed unit tests such that you only have to supply input mock data for the columns that are relevant to your unit test. If we imagine a unit test that only needs Instead of:
You should do:
Now, that won’t be relevant if you do need all columns but want to test 1 case where In that case, could you explicitly call out the
Seeds behave differently than fixtures (though understand the comparison since they're both csv files). I am also hesitant to convert empty values to |
@graciegoheen how does this behave for you when you add it as a fixture?
Here's the error message I get when I use the project files described in #9881 (comment):
But maybe I have a bjorked local environment somehow? |
If this is supported perhaps it is the best solution for both worlds (seeding & unit test fixture)? In our case we need all columns because our update/delete event consists only partial of the data. |
So I think this is going to be dependent on the warehouse you're using. For example, Snowflake is totally fine with In postgres (which is what @dbeatty10 is using), Things get funky as well when trying to cast to a string, because @dbeatty10 did a deep dive on what you can and can't cast We've had a tradeoff for seeds for awhile where:
I understand it's confusing for us to decide the opposite for fixtures:
That being said, you can define At minimum, I think we have a few things to do here:
In addition, we should decide how we want to handle this. A few options include:
I'm going to move this over to technical refinement to get input from our engineers! Thanks for the discussion. |
dbt-labs/dbt-snowflake#894 (comment) has the deep dive of casting
|
Acceptance Criteria
|
Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#5476 |
Current Behavior
I have fixture with empty value, the unit test will convert them to "" instead of null. It looks like seeding is working by converting them to null but not the case for unit test.
Expected Behavior
csv with empty value should be treating as null.
Steps To Reproduce
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: