SnowDuck
Run Snowflake SQL locally, powered by DuckDB β lightweight in-memory SQL engine for development and testing.
Why SnowDuck?
SnowDuck is a drop-in Snowflake mock that lets you run Snowflake SQL locally without a cloud connection. Perfect for:
- π§ͺ Unit Testing β Test your Snowflake queries without cloud costs
- π Local Development β Iterate faster with sub-millisecond query times
- π CI/CD Pipelines β Run dbt tests without Snowflake credentials
- π Learning β Experiment with Snowflake SQL syntax offline
Features
| Feature | Status |
|---|---|
| 100+ Snowflake Functions | β String, Date, Numeric, JSON, Array, Aggregate |
| SQL Transpilation | β Automatic Snowflake β DuckDB translation |
| Session Variables | β SET/UNSET with context persistence |
| Session Parameters | β ALTER SESSION SET/UNSET, read back with SHOW PARAMETERS |
| Identifier Case | β Unquoted names fold to upper case, as in Snowflake |
| LATERAL FLATTEN | β Full support via UNNEST |
| QUALIFY Clause | β Native DuckDB support |
| SHOW Commands | β Snowflakeβs column shapes, with TERSE / LIKE / STARTS WITH / LIMIT β¦ FROM |
| Information Schema | β Per-database Snowflake-shaped INFORMATION_SCHEMA views |
| Snowpipe Streaming API | β Full REST API mock |
| SQL REST API | β
/api/v2/statements endpoints |
| dbt Compatibility | β Verified end to end against dbt-core 1.12 / dbt-snowflake 1.12 |
Getting Started
Installation
pip install snowduck
For the REST API server:
pip install snowduck[server]
Quick Start
import snowflake.connector
from snowduck import start_patch_snowflake, stop_patch_snowflake
# Start the mock
start_patch_snowflake()
# Use Snowflake connector as normal - it's now mocked!
conn = snowflake.connector.connect(
user="test",
password="test",
account="test"
)
cursor = conn.cursor()
cursor.execute("SELECT 'Hello, SnowDuck!' AS greeting")
print(cursor.fetchone()[0]) # Hello, SnowDuck!
# Clean up
stop_patch_snowflake()
With pytest
import pytest
from snowduck import mock_snowflake
@mock_snowflake
def test_my_query():
import snowflake.connector
conn = snowflake.connector.connect(user="x", password="x", account="x")
cursor = conn.cursor()
cursor.execute("SELECT UPPER('hello') AS result")
assert cursor.fetchone()[0] == "HELLO"
Docker
Run the SnowDuck server as a container:
docker run -p 8000:8000 ghcr.io/hupe1980/snowduck:latest
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your Application β
β (snowflake-connector-python) β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β Patched
βββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β SnowDuck β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β Connector β β Dialect β β Info Schema β β
β β Layer β β Layer β β Manager β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββββββ¬βββββββββββ β
β β β β β
β ββββββββββββββββββΌββββββββββββββββββββββ β
β β β
β βββββββββΌββββββββ β
β β DuckDB β β
β β (Engine) β β
β βββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Test Coverage
507 tests passing covering:
- SQL transpilation for 100+ functions
- All DML operations (SELECT, INSERT, UPDATE, DELETE, MERGE)
- DDL operations (CREATE, DROP, ALTER)
- Session management
- dbt-snowflake compatibility (37 dedicated tests)
- Snowpipe Streaming REST API (40 tests)
License
SnowDuck is distributed under the MIT License.