{"id":35411430,"url":"https://github.com/nnnkkk7/snowflake-emulator","last_synced_at":"2026-01-13T19:46:39.643Z","repository":{"id":331410953,"uuid":"1124465116","full_name":"nnnkkk7/snowflake-emulator","owner":"nnnkkk7","description":"A lightweight Snowflake emulator built with Go and DuckDB for local development and testing","archived":false,"fork":false,"pushed_at":"2026-01-06T14:48:54.000Z","size":28161,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-07T21:43:58.890Z","etag":null,"topics":["ci-cd","cicd","database","docker","duckdb","emulator","go","golang","gosnowflake","local-development","snowflake","snowflake-emulator","sql","test","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nnnkkk7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T04:22:00.000Z","updated_at":"2026-01-06T14:48:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nnnkkk7/snowflake-emulator","commit_stats":null,"previous_names":["nnnkkk7/snowflake-emulator"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/nnnkkk7/snowflake-emulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnnkkk7%2Fsnowflake-emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnnkkk7%2Fsnowflake-emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnnkkk7%2Fsnowflake-emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnnkkk7%2Fsnowflake-emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nnnkkk7","download_url":"https://codeload.github.com/nnnkkk7/snowflake-emulator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnnkkk7%2Fsnowflake-emulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28397826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci-cd","cicd","database","docker","duckdb","emulator","go","golang","gosnowflake","local-development","snowflake","snowflake-emulator","sql","test","testing"],"created_at":"2026-01-02T14:11:19.977Z","updated_at":"2026-01-13T19:46:39.637Z","avatar_url":"https://github.com/nnnkkk7.png","language":"Go","funding_links":[],"categories":["Testing","Libraries Powered by DuckDB"],"sub_categories":["Data Profiler"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/snowflake-emulator.png\" alt=\"snowflake-emulator\" width=\"360\" /\u003e\n\u003c/p\u003e\n\nThe Go gopher was designed by the awesome [Renee French](https://reneefrench.blogspot.com/)\n\n# Snowflake Emulator\n\nA lightweight, open-source Snowflake emulator built with Go and DuckDB, designed for local development and testing.\n\n[![CI](https://github.com/nnnkkk7/snowflake-emulator/workflows/CI/badge.svg)](https://github.com/nnnkkk7/snowflake-emulator/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Go Reference](https://pkg.go.dev/badge/github.com/nnnkkk7/snowflake-emulator.svg)](https://pkg.go.dev/github.com/nnnkkk7/snowflake-emulator)\n[![GitHub Stars](https://img.shields.io/github/stars/nnnkkk7/snowflake-emulator?style=social)](https://github.com/nnnkkk7/snowflake-emulator)\n\n⭐ Like it? Give us a star!\n\n## TL;DR\n\n```bash\ndocker run -p 8080:8080 ghcr.io/nnnkkk7/snowflake-emulator:latest\n```\n\n```go\ndsn := \"user:pass@localhost:8080/TEST_DB/PUBLIC?account=test\u0026protocol=http\"\ndb, _ := sql.Open(\"snowflake\", dsn)\nrows, _ := db.Query(\"SELECT IFF(1\u003e0,'yes','no')\")  // Snowflake SQL works!\n```\n\n## Use Cases\n\n- Run integration tests locally without Snowflake credentials (Go via gosnowflake, or any language via REST API)\n- Cheap \u0026 fast CI smoke tests for Snowflake SQL\n- Validate Snowflake-ish SQL behavior before hitting real Snowflake\n\n\u003e **Note**: This is a dev/test emulator — no auth, no clustering, no external stages, no JS stored procedures. See [Limitations](#limitations) for details.\n\n## Overview\n\nSnowflake Emulator provides a [Snowflake](https://www.snowflake.com/)-compatible SQL interface backed by DuckDB for local development and testing:\n\n- **Local \u0026 CI workflows** - Run Snowflake-compatible SQL with no external dependencies\n- **Snowflake-compatible access** - [`gosnowflake`](https://github.com/snowflakedb/gosnowflake) driver support and REST API v2\n- **SQL execution** - Snowflake → DuckDB translation\n\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003ePlatform Support\u003c/b\u003e\u003c/summary\u003e\n\n| Platform | Docker | Binary |\n|----------|--------|--------|\n| Linux x86_64 (amd64) | ✅ | ✅ |\n| Linux ARM64 | ✅ | - |\n| macOS x86_64 | ✅ | - |\n| macOS ARM64 (Apple Silicon) | ✅ | - |\n| Windows (WSL2) | ✅ | - |\n\n\u003e **Note**: Binary releases are only available for Linux x86_64. This is due to DuckDB requiring CGO, which makes cross-compilation complex. For all other platforms, Docker is recommended.\n\n\u003c/details\u003e\n\n### Docker (Recommended)\n\nDocker is the recommended installation method for all platforms.\n\n```bash\n# Pull the image\ndocker pull ghcr.io/nnnkkk7/snowflake-emulator:latest\n\n# Run with in-memory database\ndocker run -p 8080:8080 ghcr.io/nnnkkk7/snowflake-emulator:latest\n\n# Run with persistent storage\ndocker run -p 8080:8080 -v snowflake-data:/data \\\n  -e DB_PATH=/data/snowflake.db \\\n  ghcr.io/nnnkkk7/snowflake-emulator:latest\n```\n\n### Build from Source (Linux x86_64)\n\nPrerequisites:\n\n- Go 1.24+\n- GCC (for DuckDB CGO)\n\n```bash\ngit clone https://github.com/nnnkkk7/snowflake-emulator.git\ncd snowflake-emulator\nCGO_ENABLED=1 go build -o snowflake-emulator ./cmd/server\n```\n\n### Run the Server\n\n```bash\n# In-memory mode (default)\n./snowflake-emulator\n\n# With persistent storage\nDB_PATH=/path/to/database.db ./snowflake-emulator\n\n# Custom port\nPORT=9090 ./snowflake-emulator\n```\n\n### Using with gosnowflake Driver\n\n```go\npackage main\n\nimport (\n    \"database/sql\"\n    \"fmt\"\n    \"log\"\n\n    _ \"github.com/snowflakedb/gosnowflake\"\n)\n\nfunc main() {\n    // Connect to local emulator\n    dsn := \"user:pass@localhost:8080/TEST_DB/PUBLIC?account=test\u0026protocol=http\"\n    db, err := sql.Open(\"snowflake\", dsn)\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer db.Close()\n\n    // Execute Snowflake SQL (automatically translated)\n    rows, err := db.Query(`\n        SELECT\n            name,\n            IFF(score \u003e= 90, 'A', 'B') AS grade,\n            NVL(email, 'no-email') AS email\n        FROM users\n    `)\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer rows.Close()\n\n    for rows.Next() {\n        var name, grade, email string\n        rows.Scan(\u0026name, \u0026grade, \u0026email)\n        fmt.Printf(\"%s: %s (%s)\\n\", name, grade, email)\n    }\n}\n```\n\n### Using REST API v2\n\n```bash\n# Submit a SQL statement\ncurl -X POST http://localhost:8080/api/v2/statements \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"statement\": \"SELECT IFF(1 \u003e 0, '\\''yes'\\'', '\\''no'\\'')\",\n    \"database\": \"TEST_DB\",\n    \"schema\": \"PUBLIC\"\n  }'\n\n# Get statement result\ncurl http://localhost:8080/api/v2/statements/{handle}\n\n# Create a database\ncurl -X POST http://localhost:8080/api/v2/databases \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"MY_DB\"}'\n\n# List warehouses\ncurl http://localhost:8080/api/v2/warehouses\n```\n\n## Next Steps\n\n| Example | Description |\n|---------|-------------|\n| [`gosnowflake/`](example/gosnowflake/) | Go driver example |\n| [`restapi/`](example/restapi/) | REST API v2 example |\n| [`docker/`](example/docker/) | Docker container example |\n\n```bash\n# Start the emulator\ngo run ./cmd/server\n\n# In another terminal, run an example\ngo run ./example/gosnowflake\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `PORT` | `8080` | HTTP server port |\n| `DB_PATH` | `:memory:` | DuckDB database path (empty for in-memory) |\n| `STAGE_DIR` | `./stages` | Directory for internal stage files |\n\n## API Endpoints\n\n### gosnowflake Protocol\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/session/v1/login-request` | POST | Session login |\n| `/session/token-request` | POST | Token refresh |\n| `/session/heartbeat` | POST | Keep-alive |\n| `/session/renew` | POST | Renew session |\n| `/session/logout` | POST | Logout |\n| `/session/use` | POST | USE DATABASE/SCHEMA |\n| `/queries/v1/query-request` | POST | Execute SQL query |\n| `/queries/v1/abort-request` | POST | Cancel query |\n\n### REST API v2\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/v2/statements` | POST | Submit SQL statement |\n| `/api/v2/statements/{handle}` | GET | Get statement status/result |\n| `/api/v2/statements/{handle}/cancel` | POST | Cancel statement |\n| `/api/v2/databases` | GET, POST | List/Create databases |\n| `/api/v2/databases/{db}` | GET, PUT, DELETE | Get/Alter/Drop database |\n| `/api/v2/databases/{db}/schemas` | GET, POST | List/Create schemas |\n| `/api/v2/databases/{db}/schemas/{schema}` | GET, DELETE | Get/Drop schema |\n| `/api/v2/databases/{db}/schemas/{schema}/tables` | GET, POST | List/Create tables |\n| `/api/v2/databases/{db}/schemas/{schema}/tables/{table}` | GET, PUT, DELETE | Get/Alter/Drop table |\n| `/api/v2/warehouses` | GET, POST | List/Create warehouses |\n| `/api/v2/warehouses/{wh}` | GET, DELETE | Get/Drop warehouse |\n| `/api/v2/warehouses/{wh}:resume` | POST | Resume warehouse |\n| `/api/v2/warehouses/{wh}:suspend` | POST | Suspend warehouse |\n| `/health` | GET | Health check |\n\n## Compatibility\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eSupported SQL Operations\u003c/b\u003e\u003c/summary\u003e\n\nThe emulator supports standard SQL operations with automatic Snowflake-to-DuckDB translation:\n\n| Category | Operations | Description |\n|----------|------------|-------------|\n| **Query** | `SELECT`, `SHOW`, `DESCRIBE`, `EXPLAIN` | Read operations with full result set support |\n| **DML** | `INSERT`, `UPDATE`, `DELETE` | Data manipulation with rows affected count |\n| **DDL** | `CREATE TABLE`, `DROP TABLE`, `ALTER TABLE` | Schema management |\n| **DDL** | `CREATE DATABASE`, `DROP DATABASE` | Database management |\n| **DDL** | `CREATE SCHEMA`, `DROP SCHEMA` | Schema namespace management |\n| **Transaction** | `BEGIN`, `COMMIT`, `ROLLBACK` | Transaction control |\n| **Data Loading** | `COPY INTO` | Bulk data loading from internal stages (CSV, JSON) |\n| **Upsert** | `MERGE INTO` | Conditional insert/update/delete operations |\n\n**Parameter Binding**: Supports positional placeholder substitution (`:1`, `:2`, `?`).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eSupported SQL Functions\u003c/b\u003e\u003c/summary\u003e\n\n| Snowflake | DuckDB | Description |\n|-----------|--------|-------------|\n| `IFF(cond, t, f)` | `IF(cond, t, f)` | Conditional expression |\n| `NVL(a, b)` | `COALESCE(a, b)` | Null value substitution |\n| `NVL2(a, b, c)` | `IF(a IS NOT NULL, b, c)` | Null conditional |\n| `IFNULL(a, b)` | `COALESCE(a, b)` | Null value substitution |\n| `DATEADD(part, n, date)` | `date + INTERVAL n part` | Date arithmetic |\n| `DATEDIFF(part, start, end)` | `DATE_DIFF('part', start, end)` | Date difference |\n| `TO_VARIANT(x)` | `CAST(x AS JSON)` | Convert to variant |\n| `PARSE_JSON(str)` | `CAST(str AS JSON)` | Parse JSON string |\n| `OBJECT_CONSTRUCT(...)` | `json_object(...)` | Build JSON object |\n| `LISTAGG(col, sep)` | `STRING_AGG(col, sep)` | String aggregation |\n| `FLATTEN(...)` | `UNNEST(...)` | Array expansion |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eSupported Data Types\u003c/b\u003e\u003c/summary\u003e\n\n| Snowflake Type | DuckDB Type |\n|----------------|-------------|\n| NUMBER, NUMERIC, DECIMAL | DOUBLE / DECIMAL(p,s) |\n| INTEGER, BIGINT, SMALLINT, TINYINT | INTEGER / BIGINT |\n| FLOAT, DOUBLE, REAL | DOUBLE |\n| VARCHAR, STRING, TEXT, CHAR | VARCHAR |\n| BOOLEAN | BOOLEAN |\n| DATE | DATE |\n| TIME | TIME |\n| TIMESTAMP, TIMESTAMP_NTZ | TIMESTAMP |\n| TIMESTAMP_LTZ, TIMESTAMP_TZ | TIMESTAMPTZ |\n| VARIANT, OBJECT | JSON |\n| ARRAY | JSON |\n| BINARY, VARBINARY | BLOB |\n| GEOGRAPHY, GEOMETRY | VARCHAR (WKT) |\n\n\u003c/details\u003e\n\n## Limitations\n\nThis emulator is designed for development and testing. The following features are not supported:\n\n- Authentication/Authorization (skipped in dev mode)\n- Distributed processing / Clustering\n- Time Travel / Zero-Copy Cloning\n- Streams, Tasks, Pipes\n- External stages (S3, Azure, GCS)\n- Stored procedures with JavaScript\n- User-defined functions\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\n[MIT](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnnkkk7%2Fsnowflake-emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnnnkkk7%2Fsnowflake-emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnnkkk7%2Fsnowflake-emulator/lists"}