-
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
[Bug] python model - dbt.ref #9742
Comments
I looked at this a little closer, and there's two possibilities for changes to be made:
1. Overriding the ref macroIt might be as simple as making a slight update to the docs about overriding the ref macro. Specifically, it looks like it needs to be this: -- extract user-provided positional and keyword arguments
{% set version = kwargs.get('version') or kwargs.get('v') %} Instead of this: -- extract user-provided positional and keyword arguments
{% set version = kwargs.get('version') %} 2. Updating the
|
Hi @dbeatty10 ! Our macro has added explicit arguments similar to this :
I'm not too sure if it's possible to handle kwargs in a macro that already has named parameter, but it does seem to work when I add an explicit
Thanks again ! |
You're welcome @ArtrCtrs -- glad it is working for you now 🎉 We've also updated the code example, so I'm going to close this as resolved via dbt-labs/docs.getdbt.com#5051. |
@dbeatty10 Hi, is this bug will be repair in the future version? |
@gaoshihang we believe we addressed this by updating the documentation here. If you are having problems with versioned python models and you have an override of the ref macro, could you try the instructions above and let us know if you still think it is a bug? |
Thanks @dbeatty10 for your reply! I'll try this method. so what I need to do is create an Macro to overwrite def() with the code in https://docs.getdbt.com/reference/dbt-jinja-functions/builtins? |
@gaoshihang we were expecting that this would only affect people that already were overwriting the Are you saying you got this error without already having an custom |
@dbeatty10 I just check the code, we already have a So if later we need overwriting the |
Yep, that's right 👍 |
many thanks to you @dbeatty10 |
Is this a regression in a recent version of dbt-core?
Current Behavior
I encounter an error when I try to dbt compile a python model that uses
dbt.ref
.macro 'dbt_macro__ref' takes no keyword argument 'v'
Expected/Previous Behavior
In version 1.3.1, dbt compiles correctly the following python model code :
initial_dataset = dbt.ref("my_base_model")
Steps To Reproduce
initial_dataset = dbt.ref("my_base_model")
dbt compile
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
While testing locally, when I patch the core/dbt/include/global_project/macros/python_model/python.sql
file (
build_ref_function
method) to remove thev
argument that raises the error from{%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}
to
{%- set resolved = ref(*_ref_args) -%}
, it seems it compiles correctly.
Perhaps I'm missing something in how to use this.
This file was modified in this MR : https://github.com/dbt-labs/dbt-core/pull/7287/files#diff-a4206d061c239c90908b351474debd4a86881235c033efbbc0c6ddc81e8f7238L13
The text was updated successfully, but these errors were encountered: