-
Notifications
You must be signed in to change notification settings - Fork 976
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
Added section to Python models doc to discuss third party packages following this the thread: https://dbt-labs.slack.com/archives/C05FWBP9X1U/p1730272033637189 #6418
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks! I think that overall this is the way we should show it and point to the relevant docs but I am just wondering if the example we show is the best one. Most people will want to upload Python packages so that they can call their favorite functions. In this example we are currently loading a CSV file. It works but it is not going to be the reason why people will want to use the |
Co-authored-by: Mirna Wong <[email protected]>
Co-authored-by: Mirna Wong <[email protected]>
Hiya @mirnawong1 and @b-per Thank you for reviewing this. It's much appreciated. @b-per with ref to your feedback, I found the below example in the Snowflake doc which gives an example of installing a package with native code via importing from Stage. Would you recommend using this instead:
Kind Regards |
Yes, this looks much closer to what people might do! We just need to update it to make it a valid dbt model. |
Thanks @b-per I did a little research and came upon this example: {{ config(
materialized = 'view'
) }}
create or replace function native_module_test_zip()
returns string
language python
runtime_version=3.9
handler='compute'
imports=('@mystage/mycustompackage.zip')
as
$$
import os
import sys
from zipfile import ZipFile
import shutil
def compute():
if os.path.exists('/tmp/mycustompackage'):
shutil.rmtree('/tmp/mycustompackage')
os.mkdir('/tmp/mycustompackage')
zippath = os.path.join(sys._xoptions["snowflake_import_directory"], 'mycustompackage.zip')
ZipFile(zippath).extractall('/tmp/mycustompackage')
sys.path.insert(0, '/tmp/mycustompackage')
# Import and call the function from mycustompackage
import mycustompackage
return mycustompackage.mycustompackage()
$$; Would that suffice? Kind Regards |
I don't think so, no. This is not a valid dbt Python model. There are a few things to change. Our docs describe what a Python model needs to have (for example a |
Querying example here: https://dbt-labs.slack.com/archives/C05FWBP9X1U/p1730894409078339 |
Hiya @mirnawong1 @b-per I'm currently querying this in ask-adapters-support. I found this example:
Mike Alfare advised: "I think mycustompackage.zip might need to be some_external_package.py. To be honest, this is not something I have seen before, but reviewing our functional tests, it seems like this could work. I'll see if I can find someone more familiar with this particular feature." I thought I'd share here incase you had any ideas. Kind Regards |
I think that both Here are other examples in the internet with the
This snowflake page as well mentions the zip Rather than waiting for more and more feedback I think that the best is to push the current version and update it later if need be. As it is, it is already providing some guidance on using the |
…cs.getdbt.com into nfiann-sf-thirdparty
Was the snippet completely changed from the one in this thread? The formatting doesn't look as good as the snippet you shared before. |
Co-authored-by: Mirna Wong <[email protected]>
Co-authored-by: Mirna Wong <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm to me!
What are you changing in this pull request and why?
I have added a section to the Python models doc to discuss third party packages following this the thread: https://dbt-labs.slack.com/archives/C05FWBP9X1U/p1730272033637189
Checklist
🚀 Deployment available! Here are the direct links to the updated files: