app icon
Snowflake SQL
0.0.1

Execute SQL queries on Snowflake data warehouse (supports OAuth authentication)

langgenius/snowflake_sql215 installs

Snowflake SQL

Execute SQL queries on Snowflake data warehouse with secure OAuth 2.0 authentication.

Author: langgenius
Version: 0.0.1
Type: Tool Plugin

Overview

The Snowflake SQL plugin enables seamless integration between Dify AI applications and Snowflake data warehouse. Execute any SQL query securely using OAuth 2.0 authentication, with support for all major SQL operations including SELECT, INSERT, UPDATE, DELETE, and DDL statements.

Key Features

  • 🔐 OAuth 2.0 Authentication - Secure, industry-standard authentication
  • 🚀 Full SQL Support - Execute SELECT, INSERT, UPDATE, DELETE, CREATE, and more
  • 📊 Rich Output Formats - Results displayed as formatted Markdown tables
  • Performance Tracking - Monitor query execution time
  • 🎯 Flexible Configuration - Per-query warehouse, database, and schema selection
  • 🛡️ Type-Safe Operations - Explicit SQL type selection for accurate result handling

Installation

Prerequisites

You need a Snowflake account with appropriate permissions to create OAuth integrations. Follow these steps to set up OAuth authentication:

1. Create OAuth Integration in Snowflake

Run the following SQL commands in Snowflake (requires role):

2. Retrieve OAuth Credentials

Copy the and values - you'll need these for plugin configuration.

3. Grant Necessary Privileges

Install in Dify

  1. Navigate to Tools > Manage Tools in your Dify workspace
  2. Search for "Snowflake SQL" in the marketplace
  3. Click Install to add the plugin
  4. Configure OAuth credentials (see Configuration section below)

Configuration

OAuth Setup

After installation, configure the following OAuth parameters:

ParameterTypeRequiredDescription
Account NameTextYesYour Snowflake account identifier (e.g., )
OAuth Client IDSecretYesClient ID from
OAuth Client SecretSecretYesClient Secret from
OAuth ScopeTextNoOptional OAuth scope (e.g., )

Authentication Flow

  1. Click Connect with OAuth in the plugin configuration
  2. You'll be redirected to Snowflake's authentication page
  3. Log in with your Snowflake credentials
  4. Authorize the application to access your Snowflake account
  5. You'll be redirected back to Dify with the connection established

The OAuth token is automatically managed and refreshed by the plugin.

Usage

Tool Parameters

ParameterTypeRequiredDefaultDescription
SQL QueryStringYes-The SQL statement to execute
SQL TypeSelectYesSELECTType of SQL operation
WarehouseStringNoCOMPUTE_WHSnowflake warehouse name
DatabaseStringNo-Target database
SchemaStringNoPUBLICTarget schema
Max RowsNumberNo100Maximum rows to return (SELECT only)

SQL Types

Select the appropriate SQL type for your query:

  • SELECT - Retrieve data (returns rows and columns)
  • INSERT - Add new records (returns affected row count)
  • UPDATE - Modify existing records (returns affected row count)
  • DELETE - Remove records (returns affected row count)
  • MERGE - Upsert operations (returns affected row count)
  • CREATE - Create database objects (returns execution status)
  • DROP - Remove database objects (returns execution status)
  • ALTER - Modify database objects (returns execution status)
  • TRUNCATE - Clear table data (returns execution status)
  • SHOW - Display metadata (returns rows and columns)
  • DESCRIBE - Describe objects (returns rows and columns)
  • OTHER - Other SQL statements

💡 Tip: Always specify the correct SQL type, especially for queries with WITH clauses, as they can be used with INSERT, UPDATE, or DELETE operations.

Examples

Example 1: Query Customer Data

Input:

Output:

Example 2: Insert Order Record

Input:

Output:

Example 3: Complex Analytics Query

Input:

Integration Scenarios

1. AI-Powered Data Analysis

Use with Dify Agent to create an intelligent data analyst that can query your database and explain results in natural language.

2. Automated Reporting Workflow

Create workflows that generate daily/weekly reports by querying Snowflake and formatting results.

3. Customer Support Chatbot

Build chatbots that can look up customer information, order status, and other data in real-time.

Output Schema

All queries return structured JSON data:

Best Practices

Security

  • ✅ Use OAuth with minimum required privileges
  • ✅ Create dedicated service roles for integration
  • ✅ Block privileged roles in OAuth integration
  • ❌ Don't grant unnecessary permissions

Performance

  • ✅ Use clauses to reduce data transfer
  • ✅ Specify appropriate parameter
  • ❌ Avoid on large tables

Query Design

  • ✅ Always specify SQL type correctly
  • ✅ Test queries in Snowflake before production use
  • ❌ Don't use dynamic SQL from untrusted input

Troubleshooting

Authentication Errors

Error: "OAuth authentication required"

Solution: Reconnect OAuth in plugin settings.

Query Errors

Error: "SQL compilation error: Object does not exist"

Solution: Verify database, schema, and table names. Check permissions.

Permission Errors

Error: "Insufficient privileges to operate on table"

Solution: Grant necessary permissions to your OAuth role.

Support

Development Notes

Plugin Structure

Local Development

Key Implementation Details

Provider ():

  • Implements OAuth 2.0 authorization code flow
  • Handles token exchange and refresh
  • Validates credentials by testing Snowflake connection

Tool ():

  • Executes SQL queries using OAuth token
  • Supports multiple SQL types (SELECT, INSERT, UPDATE, etc.)
  • Formats results as Markdown tables and JSON
  • Handles errors gracefully with detailed messages

License

Apache License 2.0

This plugin uses the following open-source libraries:

CATEGORY
Tool
TAGS
UTILITIESSEARCH
VERSION
0.0.1
langgenius·11/06/2025 09:54 AM
REQUIREMENTS
Maximum memory
256MB