The Snowflake action pack contains the following actions:
  • Search Snowflake with SQL
  • Search Snowflake with Cortex

Overview

The Snowflake Action Pack in Glean enables users to perform both direct SQL queries and Cortex Analyst (natural language) queries against Snowflake data, seamlessly integrating Snowflake’s advanced analytics into Glean agents.

Key Features

  • Natural Language Querying via Cortex Analyst: Users can issue natural language queries that are interpreted and run against Snowflake using the Cortex Analyst API for advanced analytics use cases.
  • Direct SQL Execution: Allows users to write and execute raw SQL queries on Snowflake datasets directly from Glean.
  • Semantic Model and Semantic View Support: Enables referencing semantic model or semantic view definitions to guide analyst queries in natural language mode.
  • User OAuth: Supports authenticated access, requiring users to log in with their credentials for data access.

Usage Instructions

Setup in Agent Builder

  1. Ensure the Snowflake Action Pack has been successfully set up by an admin.
  2. Create a new Glean Agent.
  3. Add the following steps to the agent:
    • Step 1: Select Trigger type > Task.
    • Step 2: Select the “Search Snowflake with Cortex” action. In the text box, add:
      For Snowflake Cortex Analyst, send the following natural language query to the tool as is without any modification: [[query]].
      Include a comma-separated list of semantic model files or semantic views and the warehouse to be used by Cortex Analyst.
    • Step 3: Select the “Respond” action. In the text box, add:
      Show me the results from the Search Snowflake with Cortex Analyst tool only. If there are more than 3 rows, show them as a table. Use the first row in the response from the tool for column names. Always show citations.
  4. Save your changes and share the agent with your teammates using the sharing link.

Usage Examples

  • Revenue Insights in Natural Language: What was the total revenue last month? using the Cortex Analyst feature and a semantic model or semantic view input.
  • Direct SQL Querying: SELECT COUNT(*) FROM customers LIMIT 5 executed directly through SQL.

Known Limitations

  • Does not support multi-turn conversations or visualizations through the Cortex Analyst interface.
  • Glean does not control the quality of Snowflake Cortex Analyst responses (dependent on Snowflake’s API output).
  • Advanced features of Snowflake Cortex Analyst (beyond simple query execution) are not supported.

Best Practices and Troubleshooting

  • Always provide a warehouse for executing SQL queries with your agents, as some users may not have a default warehouse.
  • In case of internal or external failure, the error is relayed back to the user to aid with troubleshooting.
  • To get the best results out of Cortex Analyst, ensure that the semantic models or views are extensively defined. Creating a Cortex Search Service for a few of the target columns also helps.

FAQ

  • Error: “You must specify the warehouse to use by either setting the warehouse field in the body of the request or by setting the DEFAULT_NAMESPACE property for the current user. Please set a default warehouse for your Snowflake account and provide USAGE privilege for the provided role on the warehouse.”
You need to specify which Snowflake warehouse to use. You can do this by setting the warehouse in the Snowflake warehouse field when configuring your agent, or by ensuring your user account has a default warehouse set in Snowflake. Additionally, make sure the role you are using has the necessary USAGE privilege on the warehouse. To grant this privilege, use the following command in Snowflake:
GRANT USAGE ON WAREHOUSE <WAREHOUSE> TO ROLE <ROLE>;
Replace <WAREHOUSE> with your warehouse name and <ROLE> with your role name.
  • Error: “<SNOWFLAKE_OBJECT> does not exist or is not authorized”
This error means that either the object (database, schema, table, etc.) does not exist, the name is incomplete, or your role does not have the required privileges. Ensure you provide the complete and correct qualifier for the object (e.g., DATABASE.SCHEMA.TABLE). You must also grant the necessary USAGE privilege to the Snowflake role used by the action. Here are some example commands:
-- Grant usage to a database
GRANT USAGE ON DATABASE <SET_DATABASE_NAME> TO ROLE <SNOWFLAKE_ROLE>;

-- Grant usage to a schema
GRANT USAGE ON SCHEMA <SET_DATABASE_NAME>.<SET_SCHEMA_NAME> TO ROLE <SNOWFLAKE_ROLE>;

-- Grant read access for a table
GRANT SELECT ON TABLE <SET_DATABASE_NAME>.<SET_SCHEMA_NAME>.<SET_TABLE_NAME> TO ROLE <SNOWFLAKE_ROLE>;

-- Grant read access for all tables in a schema
GRANT SELECT ON ALL TABLES IN SCHEMA <SET_DATABASE_NAME>.<SET_SCHEMA_NAME> TO ROLE <SNOWFLAKE_ROLE>;

-- Grant access to Cortex
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE <SNOWFLAKE_ROLE>;

-- Grant role access to a user
GRANT ROLE <SNOWFLAKE_ROLE> TO USER <SET_USER_NAME>;

-- Grant role access to another role (applies to all users with that role)
GRANT ROLE <SNOWFLAKE_ROLE> TO ROLE <SET_ROLE_NAME>;