-
Notifications
You must be signed in to change notification settings - Fork 79
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
dbt-unit-testing plus Python models #165
Comments
Another issue with Python models was related to model versions. But we fixed that by using the latest version of the package (v0.3.2) as suggested in issue #160. Thanks for the fix. |
We have faced the same issue. We resolved in a slightly different way. We use docker and rebuild the image on release so editing the dbt-unit-testing package file directly wasn't really a viable solution for us. We needed a way that we own, and hence version control. We use the method suggested in the readme of this repo to override the ref and source macros:
We updated this to look like this:
And then nothing needs change in your sql models, but in your python models, the signature of dbt ref calls should now be: We haven't come across a limitation yet, and it works for us. As far as we can tell you can't set the project_or_package_name variable from the python models anyway, so setting it to none when ref() is called from within a python model should be fine. |
Hey @jacksond80 ,
I have changed the macro like this {% macro source() %} and calling my Python model like this - |
@jsatyam7 I don't see anything obviously wrong, the error would suggest that you're attempted override of the ref() macro is not getting picked up. You can verify this by adding print statements to log to console so you can tell which macro gets called. Is your macros path set correctly? (Do you have other macros that work ok in the macros folder?) |
We faced an issue when dbt-unit-testing package and Python models are used in one project.
The reason is ref macro we added for the package:
I managed to fix that by modifying the code in dbt_packages/dbt_unit_testing/macros/overrides.sql:
But I'm not sure how this change may affect unit tests. Is there a better way to fix the issue if we want to avoid changing ref in all models like:
select * from {{ dbt_unit_testing.ref('stg_customers') }}
Here is an example of a Python model:
Thanks!
The text was updated successfully, but these errors were encountered: