Skip to main content

Snowflake Switchboard AI (snowflake-switchboard-ai)

PyPI version License: MIT Python 3.8+

snowflake-switchboard-ai is a metadata-driven, zero-cost query router for Snowflake and Snowpark.

It automatically inspects your query execution plan before execution to estimate projected data volumes (bytesAssigned), dynamically routing your queries to the optimal warehouse tier to maximize performance while minimizing compute costs.

🚀 Key Features

  • Zero-Cost Telemetry Analysis: Uses Snowflake's native SYSTEM$EXPLAIN_PLAN_JSON to inspect query payloads without executing them or incurring compute charges.
  • Intelligent Tier Routing: Automatically maps query byte sizes to your configured warehouse hierarchy.
  • Frictionless Execution: Provides a clean callable shorthand syntax (sb(...)) that analyzes, routes, executes, and renders results automatically.
  • Flexible Configuration: Works out of the box with sensible size defaults or accepts custom data thresholds tailored to your workload.

📦 Step-by-Step Guide

Step 1: Installation

Install the package directly from PyPI into your environment or notebook:

pip install snowflake-switchboard-ai

Step 2: Quick Start (Default Thresholds)

Simply pass your existing Snowpark session and ordered warehouse list. The switchboard automatically applies smart data size thresholds out of the box:

from switchboard import MultiTierSwitchboard

# 1. Initialize with automatic default thresholds
sb = MultiTierSwitchboard(
    session=session,
    warehouses=["xsmall_wh", "small_wh", "medium_wh", "large_wh", "xlarge_wh", "xxlarge_wh"]
)

# 2. Run queries effortlessly using callable shorthand
sb("""
    SELECT c_mktsegment, COUNT(*)
    FROM SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.CUSTOMER
    GROUP BY c_mktsegment
""")

📊 Default Threshold Mapping

When custom thresholds are not specified, MultiTierSwitchboard routes queries using these exact default payload limits:

Warehouse Tier Byte Boundary Data Volume Limit
Tier 1 (e.g., XS) < 1,000,000,000 bytes Under 1 GB
Tier 2 (e.g., Small) < 5,000,000,000 bytes Under 5 GB
Tier 3 (e.g., Medium) < 20,000,000,000 bytes Under 20 GB
Tier 4 (e.g., Large) < 50,000,000,000 bytes Under 50 GB
Tier 5 (e.g., X-Large) < 100,000,000,000 bytes Under 100 GB
Tier 6 (e.g., 2X-Large) < 500,000,000,000 bytes Under 500 GB

Step 3: Custom Thresholds (Optional)

If you want granular control over when queries switch warehouse tiers, pass your own custom byte limits via thresholds:

# Pass custom byte limits matching your warehouse boundaries:
sb = MultiTierSwitchboard(
    session=session,
    warehouses=["xsmall_wh", "small_wh", "medium_wh"],
    thresholds=[1_000_000_000, 10_000_000_000]
)

📸 Live Execution Output

Here is how snowflake-switchboard-ai looks in action inside a Snowflake Notebook:

Execution Output

⚙️ How It Works

  • Pre-Check Phase: Intercepts query execution and executes SYSTEM$EXPLAIN_PLAN_JSON(...) at zero compute cost.
  • Telemetry Analysis: Recursively parses the JSON plan tree to calculate estimated bytesAssigned.
  • Dynamic Routing: Automatically executes a fast USE WAREHOUSE <optimal_tier> before triggering data retrieval.

🛠️ Requirements

  • Python 3.8+
  • snowflake-snowpark-python >= 1.0.0

📜 License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for snowflake-switchboard-ai 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowflake-switchboard-ai 0.2.2
File Size Uploaded Provenance
snowflake_switchboard_ai-0.2.2.tar.gz 5.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for snowflake-switchboard-ai 0.2.2
File Interpreter ABI Platform
snowflake_switchboard_ai-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / snowflake_switchboard_ai-0.2.2.tar.gz

Download URL snowflake_switchboard_ai-0.2.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7c6210704f656db2e979c6e3bd212d48b469d4db17daa81f9a167b5dd99eddd
BLAKE2b-256 checksum
How to use checksums
fe94c0d057bfac9cc285ec580dc29bb5ddd9bd58bd31629e8ba1859f93f6ce57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.9

Release files / snowflake_switchboard_ai-0.2.2-py3-none-any.whl

Download URL snowflake_switchboard_ai-0.2.2-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93b548541b8a1384ae5244d4288ddcd496f8ad604e0ac6ba20618a2d7cadbf4d
BLAKE2b-256 checksum
How to use checksums
f5debbb26f4c8cbacd5cf72602ff796987d318fc6165ed97827c4a2b488920a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.9

Security for snowflake-switchboard-ai 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page