Skip to content
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

Open
wants to merge 4 commits into
base: current
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions website/docs/docs/build/python-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,40 @@ models:

**Docs:** ["Developer Guide: Snowpark Python"](https://docs.snowflake.com/en/developer-guide/snowpark/python/index.html)

#### Third-party Snowflake packages

To use a third-party Snowflake package that isn't available in Snowflake Anaconda, upload your package by following [this example](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-packages#importing-packages-through-a-snowflake-stage) then, configure `imports` in the dbt Python model to reference to the zip file in your Snowflake staging.

Here’s a complete example configuration, including using `imports` in a Python model:

```python

import sys
from snowflake.snowpark.types import StructType, FloatType, StringType, StructField

def model( dbt, session):

dbt.config(
materialized='table',
imports = ['@dbt_integration_test/iris.csv'],
use_anonymous_sproc = False
)
schema_for_data_file = StructType([
StructField("length1", FloatType()),
StructField("width1", FloatType()),
StructField("length2", FloatType()),
StructField("width2", FloatType()),
StructField("variety", StringType()),
])
df = session.read.schema(schema_for_data_file).option("field_delimiter", ",").schema(schema_for_data_file).csv("@dbt_integration_test/iris.csv")
return df

```

This example uses `imports = ['@dbt_integration_test/iris.csv'],`, which tells dbt to locate the `iris.csv` file in the designated Snowflake stage, `@dbt_integration_test`.

For more information on using this configuration, refer to [test_python_model.py](https://github.com/dbt-labs/dbt-snowflake/blob/1d299923e34c96f2e96a5215ac196658f86ce1d1/tests/functional/adapter/test_python_model.py#L90).

</div>

<div warehouse="Databricks">
Expand Down
Loading