Managing and Using Worksheets in Snowsight¶
Worksheets provide a powerful and versatile method for running SQL queries or Python code, as well as performing other Snowflake data loading, definition, and manipulation tasks.
After you open a worksheet in Snowsight, you can do any of the following:
In addition, you can write SQL statements and visualize the results. You can also write Python code.
Browse Other Worksheets from a Worksheet¶
When you open a worksheet, you can view other worksheets in the Worksheets explorer. You can search for other worksheets and manage worksheets from the Worksheets explorer.
Previewing Worksheet Contents¶
To preview the contents of a worksheet, you can hover over the name of the worksheet in the Worksheets explorer. The preview also shows the role used to run the worksheet.
From the preview, you can also copy the contents of the worksheet. Hover over the worksheet contents preview and select the Copy button that appears.
Update Worksheets with Keyboard Shortcuts¶
Snowsight provides keyboard shortcuts to help you quickly navigate and edit queries in worksheets. For example, you can move your cursor within a worksheet, perform find and replace, copy lines, format queries, and more using hotkeys.
To see all available keyboard shortcuts, open a worksheet and press [CMD]+[SHIFT]+[?] on a Mac keyboard or [CTRL]+[SHIFT]+[?] on a Windows keyboard.
You can also hover over the tab for the worksheet and select , then choose Show Shortcuts to view the shortcuts.
Change the Session Context for a Worksheet¶
Set the session context for a worksheet to define the role and warehouse to use to run the contents of a worksheet. The worksheet context is preserved for future sessions.
Note
You cannot choose multiple roles. The context selector does not support secondary roles. To enable secondary roles in a SQL worksheet, run USE SECONDARY ROLES.
The role context for a worksheet determines which operations can be performed on Snowflake objects based on the access control privileges granted to the role.
To set the session context for a worksheet, do the following:
Sign in to Snowsight.
Select Worksheets to open the list of worksheets.
Open a worksheet.
Open the context selector.
Select a role to run the worksheet as.
Select a warehouse that the role has privileges to use.
Select anywhere outside the drop-down to close the context selector.
Note
Each worksheet is a unique session and can use roles different from the role you select on the user menu (your active role). Changing your active role does not change the role assigned to the worksheet with the context selector.
Resuming and Resizing Warehouses¶
Before or after you run your worksheet, you might need to resume or resize your warehouse.
You must have MODIFY or OWNERSHIP privileges on the warehouse to alter warehouse details.
To view and adjust warehouse details using the context selector, do the following:
Sign in to Snowsight.
Select Worksheets to open the list of worksheets.
Open a worksheet.
Open the context selector.
Select the Show warehouse details icon.
For the Status option, select the status and choose Resume if the warehouse is suspended.
For the Size option, select the size and choose a different size.
Select anywhere outside the drop-down to close the context selector.
Managing Open Worksheets¶
After you open a worksheet, select the visible when you hover over the tab for a worksheet
to manage the open worksheet in the following ways:
Rename the worksheet.
Duplicate the worksheet.
Delete the worksheet.
When you have an open worksheet, you can also view and manage other worksheets in the Worksheets explorer:
Search for other worksheets.
Rename, duplicate, delete, or move the worksheet using the
visible when you hover over the name of a worksheet.
Identify which worksheets are open in a tab using the worksheet icon. A filled-in icon indicates a worksheet open in a tab.
Organizing Worksheets in Folders¶
You can organize and manage worksheets in folders using Snowsight.
Sharing Worksheets and Folders¶
You can share worksheets and folders of worksheets with other Snowflake users in your account. You can only share worksheets directly with users who have previously signed in to Snowsight. If you want to share with someone who has not yet signed in to Snowsight, share a link instead.
Sharing a worksheet or worksheet folder lets you collaborate with your colleagues on that worksheet and lets the recipients of a shared worksheet edit or view the worksheet contents, view the results, run the worksheet, or duplicate the shared worksheet. See Permissions for Shared Worksheets.
Sharing Worksheets Across Accounts¶
Worksheets are not Snowflake objects, so cannot be replicated or shared across accounts. If you want to share the contents of a worksheet with users in another Snowflake account, copy the contents and share it with users in the account outside of Snowflake.
Managing Worksheet History and Versions¶
New versions of a worksheet are saved when you make changes and run a SQL query or the code in the worksheet.
When making changes to worksheets and managing worksheet versions, consider the following:
When you share a worksheet with other users, users with edit permissions can view past versions of the worksheet. All users that you share a worksheet with can view results for the most recent version of the worksheet.
Whenever someone with permissions runs a worksheet, a new version of the worksheet is saved.
If you make changes to the worksheet and they seem to disappear, use the version history to open the saved draft with your changes.
The most recently run version of the worksheet is the version visible to collaborators.
If you make changes to the worksheet that you want to be visible to the users with whom you shared the worksheet, you must run the worksheet.
If multiple users edit and run a shared worksheet at the same time, each run of the worksheet creates a new version. The most recently run version of the worksheet is the one visible when you open or refresh the worksheet.
Switching Worksheet Versions¶
If you want to view past versions of a worksheet, do the following:
Sign in to Snowsight.
Select Worksheets to open the list of worksheets.
Open the worksheet.
Select Code Versions for the worksheet.
From the list of worksheet versions, select the timestamp of the version that you want to view.
Review and optionally copy the worksheet details for that version.
Select Close to return to the current version of the worksheet.
If you want to view the results of a past worksheet run, view the Query History for the worksheet. See View Query History.
Stored Results for Past Worksheet Versions¶
Results for queries executed in worksheets are cached for up to 90 days, or 25 worksheet versions, whichever is greater. This cache is included in the data storage usage for your account.
Internal Snowflake Objects for Worksheets¶
Snowflake creates the following internal objects to support using worksheets in Snowsight:
Object Type |
Name |
---|---|
Security integration |
WORKSHEETS |
Blobs |
WORKSHEETS_APP |
Database |
WORKSHEETS_APP |
User |
WORKSHEETS_APP_USER |
Roles |
APPADMIN, WORKSHEETS_APP_RL |
These internal objects are used to cache query results in an internal stage in your account. This cached data is encrypted and protected by the key hierarchy for the account.
The limited privileges granted to the internal role only allow Snowsight to access the internal stage to store those results. The role cannot list objects in your account or access data in your tables.
The Snowsight user and role are returned when you query the USERS and ROLES views, respectively, in the ACCOUNT_USAGE schema in the SNOWFLAKE shared database. SHOW <objects> statements do not return these internal objects.