$ show tekumara/fakesnow
fakesnow is a Python library that provides a local, in-memory fake implementation of the Snowflake database connector. It uses DuckDB as the underlying SQL engine and sqlglot to transpile Snowflake SQL dialect into DuckDB-compatible queries. The library monkey-patches `snowflake.connector.connect` and `snowflake.connector.pandas_tools.write_pandas`, enabling developers to run Snowflake-dependent code entirely locally without a real Snowflake account. It also includes an optional HTTP server that mimics Snowflake's REST API, allowing non-Python clients (JDBC, Go, .NET) to connect. The project is primarily a test double and development tool, with a strong emphasis on behavior equivalence to real Snowflake. It supports a wide range of Snowflake SQL features, including DDL, DML, COPY INTO, MERGE, semi-structured data (JSON), sequences, stages, file formats, and session variables. The codebase is well-structured with a modular transform pipeline, extensive tests, and CI/CD pipelines for release. However, some features are partially implemented or marked as not yet supported, and the project is tightly coupled to evolving dependencies (DuckDB, sqlglot) which may cause drift.
The LLM identified 4 files worth highlighting for reuse:
Implements a chain of ~70 composable SQL transforms that rewrite Snowflake syntax into DuckDB-compatible SQL. Each transform is a function that takes a parsed sqlglot expression and returns a modified expression. The pipeline is ordered and documented with inter-transform dependencies. This pattern is highly reusable for any project that needs to transpile between SQL dialects or apply a series of syntax transformations in a modular, testable way.
Handles conversion between DuckDB result tables and Snowflake's Arrow IPC format (base64-encoded rowset). It builds Arrow schemas matching Snowflake's metadata (structs for timestamps, logical type annotations) and serializes them. This component demonstrates a clean separation between internal representation and wire format, and is reusable for any project that needs to produce Snowflake-compatible Arrow data from a different engine.
Implements Snowflake's COPY INTO command for loading data from local files, stages, or S3 (via moto mock). Supports CSV and Parquet formats with options like FORCE, PURGE, ON_ERROR, MATCH_BY_COLUMN_NAME. It manages load history in a dedicated table and simulates Snowflake's behavior for validated vs. loaded rows. This module is a self-contained data ingestion pipeline that can be extracted for any system needing a local fake of cloud-based data loading.
Provides parameter binding for Snowflake SQL queries, supporting pyformat (named), qmark (positional), and named styles. It converts Python parameters to DuckDB-compatible bindings while handling type conversions (e.g., datetime, bytes). The module is isolated and implements a well-defined interface that could be reused for any SQL engine that needs to accept multiple parameter styles from a Snowflake client.