Registry / workflow / dagster-snowflake

dagster-snowflake

JSON →
library0.29.20pypypi✓ verified 23d ago

The `dagster-snowflake` library provides an integration between Dagster and Snowflake, enabling data engineers to orchestrate, observe, and manage data pipelines that interact with the Snowflake AI Data Cloud. It allows connecting to Snowflake as a resource, building assets backed by Snowflake tables and views, and utilizing Snowflake as a data warehouse within Dagster pipelines. The library's current version is 0.29.0, released in conjunction with Dagster core, which typically has frequent updates.

pip install dagster-snowflake
INSTALL
IMPORT
SIG · DAGSTER-SNOWFLAKE
D
dagster-snowflake
workflowpythonv0.29.20
Install
27.6s avg
Import
14203ms
Disk
584MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.29.20 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 27.6s · import 14.203s · 580MB
584MB installed
● package 584MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SnowflakeResource
from dagster_snowflake import SnowflakeResource
SnowflakePandasIOManager
from dagster_snowflake_pandas import SnowflakePandasIOManager
SnowflakePySparkIOManager
from dagster_snowflake_pyspark import SnowflakePySparkIOManager
build_snowflake_io_manager
from dagster_snowflake import build_snowflake_io_manager
from dagster_snowflake_pandas import build_snowflake_io_manager
This is a legacy API for constructing IO managers; newer patterns often use `SnowflakePandasIOManager` or `SnowflakePySparkIOManager` directly.

This quickstart demonstrates how to define a Dagster asset that connects to Snowflake using `SnowflakeResource`. It uses environment variables for secure credential management and performs a simple SQL operation (table creation and data insertion) within the asset's compute function.

import os from dagster import asset, Definitions, EnvVar from dagster_snowflake import SnowflakeResource @asset def my_snowflake_asset(snowflake: SnowflakeResource): """An example Dagster asset that interacts with Snowflake.""" with snowflake.get_connection() as conn: cursor = conn.cursor() # Example: Create a table if it doesn't exist and insert data cursor.execute( """ CREATE TABLE IF NOT EXISTS my_database.my_schema.my_table ( id INT, name VARCHAR );" ) cursor.execute("INSERT INTO my_database.my_schema.my_table (id, name) VALUES (1, 'Alice');") cursor.execute("INSERT INTO my_database.my_schema.my_table (id, name) VALUES (2, 'Bob');") result = cursor.execute("SELECT COUNT(*) FROM my_database.my_table").fetchone() print(f"Rows in my_table: {result[0]}") return {'rows_processed': result[0] if result else 0} defs = Definitions( assets=[my_snowflake_asset], resources={ "snowflake": SnowflakeResource( account=EnvVar("SNOWFLAKE_ACCOUNT"), user=EnvVar("SNOWFLAKE_USER"), password=EnvVar("SNOWFLAKE_PASSWORD"), database=EnvVar("SNOWFLAKE_DATABASE"), schema=EnvVar("SNOWFLAKE_SCHEMA"), warehouse=os.environ.get("SNOWFLAKE_WAREHOUSE", ""), # Optional role=os.environ.get("SNOWFLAKE_ROLE", "") # Optional ) }, ) # To run this locally, set the following environment variables: # export SNOWFLAKE_ACCOUNT="your-account-identifier" # export SNOWFLAKE_USER="your-username" # export SNOWFLAKE_PASSWORD="your-password" # export SNOWFLAKE_DATABASE="your-database" # export SNOWFLAKE_SCHEMA="your-schema" # (Optional) export SNOWFLAKE_WAREHOUSE="your-warehouse" # (Optional) export SNOWFLAKE_ROLE="your-role" # Then run `dagster dev -f your_file_name.py`
Debug
Known issues
breakingPython 3.6 and 3.8 are no longer supported. `dagster-snowflake` dropped Python 3.6 support due to its underlying `snowflake-connector-python` dependency, and Dagster core no longer supports Python 3.8 (EOL 2024-10-07).
fix
Upgrade to Python 3.10, 3.11, 3.12, or 3.13 and ensure all Dagster and `dagster-snowflake` packages are compatible with your chosen Python version. The library currently requires Python <3.15, >=3.10.
affects: <=0.22.x for Py3.6, <=1.12.x for Py3.8
gotchaWhen loading Pandas DataFrames with timestamp columns to Snowflake, `snowflake-connector-python` (v3.5.0+) may cause data corruption if timestamps are not timezone-aware. The `SnowflakePandasIOManager` attempts to mitigate this by assigning UTC if no timezone is present.
fix
Ensure all timestamp data in Pandas DataFrames is timezone-aware (e.g., using `.dt.tz_localize('UTC')` or `.dt.tz_convert('UTC')`) before writing to Snowflake via `dagster-snowflake-pandas`.
affects: snowflake-connector-python>=3.5.0
gotchaSnowflake costs and query performance can be significant issues if not managed correctly. Common anti-patterns include full table scans, inefficient joins, or using Snowflake for high-concurrency, low-latency applications.
fix
Utilize Snowflake's query profiler to optimize SQL queries within your Dagster assets. Implement efficient warehouse usage, consider connection pooling, and separate schemas for different data stages (raw, staging, production). Dagster provides observability to help identify bottlenecks.
affects: All versions
gotchaSchema-level permissions with Snowflake future grants can be complex, especially when dbt/Dagster recreates tables. Database-level future grants may not be sufficient, leading to lost SELECT access for reporting roles.
fix
Carefully configure schema-level future grants (e.g., `GRANT SELECT ON FUTURE TABLES IN SCHEMA ... TO ROLE ...`) in Snowflake to ensure consistent access when tables are re-materialized or recreated.
affects: All versions
gotchaSensitive credentials (account, user, password, private key) for Snowflake should always be managed securely using environment variables or a secrets manager, not hardcoded directly in code.
fix
Use `EnvVar` (e.g., `EnvVar("SNOWFLAKE_PASSWORD")`) within Dagster resource configurations to retrieve credentials from environment variables. For more advanced setups, integrate with a dedicated secret management system.
affects: All versions
deprecatedThe `build_snowflake_io_manager` function is considered a legacy API for constructing I/O managers.
fix
For new projects or refactoring, prefer using explicit I/O manager classes like `SnowflakePandasIOManager`, `SnowflakePySparkIOManager`, or `SnowflakePolarsIOManager` directly within your `Definitions` resources.
affects: All versions, but more pronounced with newer Dagster releases.
Errors
Common errors & fixes
AttributeError: 'str' object has no attribute '_execute_on_connection'
This error typically occurs when `dagster-snowflake` is used with a version of SQLAlchemy that is incompatible, specifically SQLAlchemy 2.0.0 or higher, which `dagster-snowflake` has historically not supported.
fix
Downgrade SQLAlchemy to a version compatible with `dagster-snowflake` (e.g., `sqlalchemy<2.0.0`), or check for a newer version of `dagster-snowflake` that explicitly supports SQLAlchemy 2.0.0+.
snowflake.connector.errors.ProgrammingError: No active warehouse selected
This error indicates that the Snowflake connection was successfully established, but no active warehouse was specified in the `SnowflakeResource` configuration or the specified warehouse is suspended or inaccessible to the configured role.
fix
Ensure that the `warehouse` key is correctly configured in your `SnowflakeResource` definition, and that the specified warehouse exists, is active, and the connecting user/role has permission to use it. For example: `warehouse="your_warehouse_name"`.
SQL compilation error: Syntax error line 1 at position XX unexpected 'digit'
When using `SnowflakePandasIOManager`, this error often arises in newer `dagster-snowflake-pandas` versions because column names in a DataFrame that are not valid Snowflake identifiers (e.g., starting with a number like '5_stars') are no longer automatically quoted, leading to SQL syntax errors during table creation or data loading.
fix
Rename DataFrame columns to be valid Snowflake identifiers (start with a letter or underscore), or if supported by a future `dagster-snowflake-pandas` version, enable explicit quoting of identifiers if an option becomes available.
ModuleNotFoundError: No module named 'snowflake.sqlalchemy'
This `ModuleNotFoundError` can occur due to dependency conflicts, specifically when the `pydantic` version required by `dagster` (typically `<1.10.7`) clashes with the `pydantic` version required by `snowflake-sqlalchemy` or `snowflake-connector-python` (typically `>=1.10.7`), preventing `snowflake.sqlalchemy` from being properly installed or imported.
fix
Adjust your project's `pydantic` dependency to be compatible with both `dagster` and `snowflake-connector-python` (e.g., by finding a `pydantic` version that satisfies both ranges, or by upgrading `dagster` if a newer version supports a wider `pydantic` range). You might need to explicitly install `snowflake-sqlalchemy` if it's missing: `pip install snowflake-sqlalchemy`.
Upgrade
Version history
0.29.20latest on PyPI · released Aug 27, 2026
Audit
Dependencies
dagsterrequiredCore Dagster framework, required for all integrations.
snowflake-connector-pythonrequiredUnderlying Python driver for Snowflake connectivity.
pandasoptionalRequired for `dagster-snowflake-pandas` to handle Pandas DataFrames.
pysparkoptionalRequired for `dagster-snowflake-pyspark` to handle PySpark DataFrames.
polarsoptionalRequired for `dagster-snowflake-polars` to handle Polars DataFrames.
pythonrequiredRequires Python version <3.15 and >=3.10.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
dagster-snowflake — pip install dagster-snowflake · libregistry