Using Snowflake Copilot inline¶
Snowflake Copilot inline is an expansion of the existing Snowflake Copilot experience that gives you the ability to query Snowflake Copilot from within your SQL code. For information about Snowflake Copilot, see Using Snowflake Copilot.
Snowflake Copilot inline is only supported in Workspaces. For information about Workspaces, see Workspaces.
Note
Snowflake Copilot inline is natively supported in the following regions:
AWS US West 2 (Oregon)
AWS US East 1 (N. Virginia)
To use Snowflake Copilot in other regions, set the CORTEX_ENABLED_CROSS_REGION
parameter.
Within this parameter, you can either:
Provide a list of values that include at least one of the supported regions.
Set it to
ANY_REGION
.
For information about how to use the CORTEX_ENABLED_CROSS_REGION
parameter, see How to use the cross-region inference parameter.
Access control requirements¶
The COPILOT_USER database role in the SNOWFLAKE database includes the privileges that allow users to use Snowflake Copilot features. By default, the COPILOT_USER role is granted to the PUBLIC role. The PUBLIC role is automatically granted to all users and roles, so this allows all users in your account to use Snowflake Copilot features.
In addition to the COPILOT_USER requirement, users must have the CORTEX_USER role. The CORTEX_USER database role in the SNOWFLAKE database includes the privileges that allow users to call Snowflake AISQL functions. By default, the CORTEX_USER role is granted to the PUBLIC role. The PUBLIC role is automatically granted to all users and roles, so this allows all users in your account to use the Snowflake AISQL functions.
Snowflake Copilot inline requires that the user has access to the claude-3.5-sonnet
model. To ensure all users have access to this model, make sure that claude-3.5-sonnet
is included in the model allowlist and is not limited by role-based access control (RBAC). For more information about controlling model access, see Control model access.
If users have the correct permissions, they see the Snowflake Copilot inline sparkle icon in Workspaces. They can use the inline interface to interact with Snowflake Copilot.
To remove access to Copilot inline, you must revoke access to either CORTEX_USER or COPILOT_USER. If you don’t want all users to have this privilege, you can revoke access to the PUBLIC role and grant access to specific roles. For example, to revoke access from the PUBLIC role, use the following query:
USE ROLE ACCOUNTADMIN;
REVOKE DATABASE ROLE SNOWFLAKE.COPILOT_USER
FROM ROLE PUBLIC;
REVOKE DATABASE ROLE SNOWFLAKE.CORTEX_USER
FROM ROLE PUBLIC;
You can then grant access as needed. For information about limiting access to Snowflake Copilot, see Limit access to Copilot.
Supported use cases¶
Explore your data by asking open-ended questions to learn about the structure and nuances of a new dataset.
Generate SQL queries with questions in natural language.
Improve your queries by asking Snowflake Copilot to help you assess query efficiency, find optimizations, or explain what the query does.
Fix syntax errors by asking Snowflake Copilot to fix your query.
Limitations¶
Snowflake Copilot inline has the following limitations:
Support for the following languages:
English
French
German
Spanish
Italian
Portuguese
Arabic
Hindi
Chinese
Japanese
Korean
SQL
- No access to your data
Snowflake Copilot does not have access to the data inside your tables. If you want to filter on a particular value of a column, you should provide that value. For example, if you ask Snowflake Copilot to return all rows with a column A value equal to “X”, you should provide the value “X” in your request. For more information, see the Construct and run a SQL Statement example.
- Delayed response
Snowflake Copilot might take a second to complete a response, depending on the length of the response provided.
- SQL suggestions may not always work
Snowflake Copilot may sometimes suggest queries that contain invalid SQL syntax or non-existent tables or columns.
- Delay in detecting new databases, schemas, and tables
It may take up to 3-4 hours for Snowflake Copilot to recognize newly created databases, schemas, and tables.
- Limited number of tables and columns considered
To generate a response, Snowflake Copilot first searches for tables and columns most relevant for your request. The search results are then ranked by relevancy and only the top 10 tables and top 10 columns from each of those tables in the results are considered when generating a response.
- Snowflake Copilot inline does not support feedback
You cannot upvote or downvote the suggestions that Snowflake Copilot inline gives you.
How to use Snowflake Copilot inline¶
Snowflake Copilot inline requires no additional setup. Remember the following points when using Snowflake Copilot:
Each session with Snowflake Copilot inline is associated with a particular file in your Workspace.
You don’t need to have a database and schema in use during your session to use Snowflake Copilot inline.
Snowflake Copilot uses the names of your databases, schemas, tables, and columns and also the data types of your columns to determine what data is available to query.
For optimal performance, use meaningful names for databases, schemas, tables, and columns, and ensure that columns are assigned the appropriate data type.
Snowflake Copilot inline considers the following sources, but does not store the data from them:
Contents of the current file, including SQL queries and code.
Context of the current file, including database, schema, and role.
User supplied input.
Snowflake documentation or general SQL knowledge.
Data from your account.
To begin using Snowflake Copilot inline:
Open a Workspace. For information about Workspaces, see Workspaces.
Enter the CMD+I shortcut.
In the message dialog, enter your request. Then click the send icon to submit it. Snowflake Copilot provides a response inline and shows a diff with the existing code.
Choose one of the following:
Select Accept to accept the suggested changes.
Select Reject to reject the suggested changes.
Select Close to end the session.
Add custom instructions¶
Snowflake Copilot inline does not accept custom instructions to customize how it responds.
Examples¶
The following sections provide examples that demonstrate how to:
These examples use a sample dataset from the Snowflake Marketplace.
Prerequisites¶
The examples in this section use the Cybersyn Github Archive dataset from the Snowflake Marketplace:
Install the Cybersyn Github Archive dataset in your account.
Open a Workspace. For information about Workspaces, see Workspaces.
Select the Cybersyn Github Archive database and schema.
Construct and run a SQL Statement¶
The following example demonstrates how to use Snowflake Copilot inline to generate SQL queries.
Enter the following question in the Snowflake Copilot inline message box, and select the send icon to submit it. Snowflake Copilot responds with a SQL query that answers your question.
How many stars were given in the past year?
Review the changes. Lines highlighted in red are removed and lines highlighted in green are added.
Select Accept to accept the suggested changes.
Snowflake Copilot does not have access to the data inside your tables. If you want Snowflake Copilot to construct a SQL statement that filters based on a specific value of a column, you must provide the value to filter on.
Enter the following question in the message box and select the send icon. Snowflake Copilot inline responds with a SQL query that uses the filter value that you provided.
What are all of the repo names that start with 'snowflake'?
Review the changes. Lines highlighted in red are removed and lines highlighted in green are added.
Select Accept to accept the suggested changes.
Add comments to a SQL statement¶
The following example demonstrates how to use Snowflake Copilot to add comments to a SQL statement you’re working on.
In the Snowflake Copilot inline message box, type the following question:
Can you add comments to this query?
Snowflake Copilot responds by adding a comment that explains the purpose of each line in the provided query.
Fix a SQL Statement¶
The following example demonstrates how to use Snowflake Copilot inline from a Workspace to fix a SQL statement.
Focus your cursor over the target query with a syntax error.
Enter the CMD+I shortcut to bring up the Snowflake Copilot inline window.
Ask Snowflake Copilot to fix your query.
Review the changes. Lines highlighted in red are removed and lines highlighted in green are added.
Select Accept to accept the suggested changes.
Tips for using Snowflake Copilot¶
For tips about using Snowflake Copilot, see Tips for using Snowflake Copilot.
Costs¶
Snowflake Copilot is currently free to use. Details on pricing and billing are planned but you will be notified before any charges are applied for this feature.
Legal notices¶
This feature leverages third party models and/or services, as previously described on this page. Where the models and/or services used are provided on the Snowflake Model and Service Flowdown Terms page, use of those models and/or services are also subject to those terms.
For additional information, refer to Snowflake AI and ML.