Add upstream to python models #6841
leo-schick
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
@leo-schick Thanks for opening, and explaining the use case! Your request sounds a lot like the one outlined here: #5995 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here the definition for the proposed functions: class dbtObj:
def add_upstream(model_name: str) -> None:
"""
Adds a model as upstream to the current python model
Args:
model_name: The dbt model name to reference to.
"""
raise NotImplementedError()
def upstream_model(model_name: str) -> None:
"""
Returns the database resolved reference to a model and adds it as upstream to the current python model.
Args:
model_name: The dbt model name to reference to.
"""
raise NotImplementedError() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What is the problem to be solved?
Currently, upstreams for python models are detected when calling
dbt.ref(...)
ordbt.source(...)
. These commands do not only set the upstream but return the dataframe object as well.Now sometimes I use custom materialization in models e.g. to create a tabular function. These work well and create the required tabluar function. Now when I use the tabular function, I cannot use
dbt.ref(...)
because this returns the result of a table or view. When I try this, I get the following error:I am able to use the SQL function by writing
session.sql(" ... FROM dbt_dev.my_function_name")
in the python model, but this does not add it as upstream.So, I need a way to tell the python model that a specific dbt model (in my example the model which creates the SQL function) is upstream to the current model.
Possible solution
Add a new function which supports to add a specific model as upstream to the current model.
Example:
Or even better, add a function which resolves a model name and adds the model as upstream, but does not return the data frame (which does not exist for the SQL procedure).
Example:
Beta Was this translation helpful? Give feedback.
All reactions