Snowflake
Connect Snowflake to Formula Bot with step-by-step user and role setup, warehouse configuration, multi-schema access, and cost optimization tips.
Connect your Snowflake data warehouse to analyze data using natural language queries and create visualizations.
Prerequisites
- A Snowflake account
- User credentials with appropriate permissions
- Warehouse access for running queries
Connection Details
| Field | Description | Example |
|---|---|---|
| Account | Snowflake account identifier | xy12345.us-east-1 |
| Username | Snowflake user | FORMULABOT_USER |
| Password | User password | ******** |
| Warehouse | Compute warehouse | COMPUTE_WH |
| Database | Default database | ANALYTICS |
| Schema | Default schema (optional) | PUBLIC |
| Role | User role (optional) | ANALYST |
Setup Steps
1. Create a User for Formula Bot
-- Create a role for Formula Bot
CREATE ROLE FORMULABOT_ROLE;
-- Grant warehouse usage
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE FORMULABOT_ROLE;
-- Grant database access
GRANT USAGE ON DATABASE ANALYTICS TO ROLE FORMULABOT_ROLE;
GRANT USAGE ON SCHEMA ANALYTICS.PUBLIC TO ROLE FORMULABOT_ROLE;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS.PUBLIC TO ROLE FORMULABOT_ROLE;
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS.PUBLIC TO ROLE FORMULABOT_ROLE;
-- Create the user
CREATE USER FORMULABOT_USER
PASSWORD = 'your-secure-password'
DEFAULT_ROLE = FORMULABOT_ROLE
DEFAULT_WAREHOUSE = COMPUTE_WH
DEFAULT_NAMESPACE = ANALYTICS.PUBLIC;
-- Assign the role
GRANT ROLE FORMULABOT_ROLE TO USER FORMULABOT_USER;
2. Find Your Account Identifier
Your account identifier is in your Snowflake URL:
https://xy12345.us-east-1.snowflakecomputing.com- Account identifier:
xy12345.us-east-1
Or check in Snowflake:
SELECT CURRENT_ACCOUNT();
3. Connect in Formula Bot
- Go to Connectors > Add Connector
- Select Snowflake
- Enter your connection details
- Click Test Connection
- Save when successful
The warehouse must be running for the connection test. Formula Bot will use it for all queries.
Warehouse Configuration
Choose an appropriate warehouse:
| Size | Best For |
|---|---|
| X-Small | Simple queries, small datasets |
| Small | Typical analytical queries |
| Medium | Complex joins, large aggregations |
Formula Bot uses your specified warehouse for all queries. Monitor usage in Snowflake's billing section.
Example Questions
Basic Analysis
- "Show me the schema of the orders table"
- "How many records are in the customers table?"
- "List all tables in the analytics database"
Business Questions
- "What were total sales last quarter?"
- "Show the top 20 products by revenue"
- "Calculate customer lifetime value by segment"
Time Series
- "Show daily active users trend"
- "Compare this month to the same month last year"
- "What's the weekly growth rate?"
Complex Analysis
- "Calculate cohort retention over 12 months"
- "Find products frequently bought together"
- "Segment customers by purchase behavior"
Working with Multiple Schemas
Grant access to additional schemas as needed:
GRANT USAGE ON SCHEMA ANALYTICS.MARKETING TO ROLE FORMULABOT_ROLE;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS.MARKETING TO ROLE FORMULABOT_ROLE;
Reference schemas in your questions:
- "Query the marketing.campaigns table"
- "Show data from sales.transactions"
Data Sharing
If you use Snowflake Data Sharing:
- Grant access to shared databases:
GRANT IMPORTED PRIVILEGES ON DATABASE shared_data TO ROLE FORMULABOT_ROLE;
- Reference shared data in queries normally
Troubleshooting
Connection Failed
- Verify account identifier format
- Check username and password
- Ensure the warehouse exists and you have usage rights
Warehouse Suspended
- The warehouse may be auto-suspended
- Formula Bot will auto-resume it if configured
- Check warehouse auto-resume settings
Permission Errors
- Verify role has SELECT on the tables
- Check USAGE on database and schema
- Confirm warehouse access is granted
Query Timeout
- Increase warehouse size for complex queries
- Add filters to reduce data processed
- Ask for aggregated results
Cost Optimization
Warehouse Size
Use the smallest warehouse that meets your needs. X-Small is often sufficient for typical queries.
Auto-Suspend
Configure your warehouse to auto-suspend when idle:
ALTER WAREHOUSE COMPUTE_WH SET AUTO_SUSPEND = 60;
Query Efficiency
Formula Bot optimizes queries, but you can help by:
- Specifying date ranges
- Asking for aggregates instead of raw data
- Limiting result sets