Workspaces¶
Overview¶
Workspaces provides a unified editor for creating, organizing, and managing code across multiple file types, allowing you to analyze data, develop models, and build pipelines - all in one tool. Workspaces are private to you and offer a development environment where you can build, experiment, and test your work.
Prerequisites¶
Default secondary roles must be set to
ALL
for any user to use Workspaces. This setting is enabled by default through BCR-1692.
The Workspaces environment¶
Workspaces is a new editor composed of six sections or panes:
Workspaces - One area for all your files and folders. Drag and drop to move files between folders.
Worksheets - Open and edit your old worksheets.
Object Explorer - View the databases you can query. Filter and search for objects.
Editor - Edit queries and split to view multiple files at the same time.
Results - Results can be split or pinned for easy comparison.
Query History - View the history of all queries you’ve run for the current file or across all files.
Default workspace¶
Each user has a default workspace named “My Workspace” automatically provisioned by Snowflake. You can also create a new workspace from the Workspaces menu. The default workspace cannot be deleted or renamed.
Worksheets¶
In Workspaces, you can open and edit worksheets you own or have any permissions on. However, edits will not be saved if you only have view permissions on the worksheet. To convert a worksheet into a file in a workspace, drag it to a folder inside the workspace.
Query History¶
Query History is located at the bottom of the editor and includes two modes: Current File and All Files.
Current File - Shows historical queries from the file currently open and selected in the editor.
All Files - Displays all historical queries you have run across all files.
Object Explorer¶
The Object Explorer contains a hierarchical view of all databases in your account, the schemas for each database, and other objects, organized
by type. Use the filter to search for objects. You can also filter out unusable objects to simplify your view by selecting Show databases I can query.
The options available in the vertical ellipsis (more actions) button vary by object type, but include features such as
placing names in the editor, copying names, and viewing definitions.
Create and work with files and folders¶
In a workspace you can use familiar IDE and source control conventions to author, organize, and run code.
To create a new file or folder in your workspace:
Sign in to Snowsight.
Select Projects » Workspaces in the left-side navigation menu.
Select the + next to the appropriate folder.
- Select an option to create a new file or folder, or upload an existing file or folder:
SQL File - Creates a new, blank SQL file in the editor as a tab. By default, .sql is appended to unnamed files. The editor recognizes it as a SQL file, enabling syntax highlighting and autocomplete.
File - Creates a new file. Name the file and its extension. If the extension is recognized by the editor (for example, Java, JS, Scala, etc.), code highlighting and autocomplete are enabled.
Folder - Creates a new, empty folder inside the workspace.
Upload Files - Upload one or more files to any location in your workspace. The editor detects the file type based on its extension, applying the appropriate icon and behavior when opened.
Upload Folder - Select one or more files or folders to add to the selected Workspace.
Manage files¶
You can rename, delete, move, and organize your workspaces, files, and folders.
To rename or delete a file, folder, or workspace:
Hover over the target and select the vertical ellipsis
(more actions).
Select Rename or Delete. If you choose to delete, you are prompted to confirm.
To create a folder in a workspace, select the + next to the workspace or an existing folder.
To organize files and folders, drag any file or folder into a different location in the same workspace. You can also drag and drop a worksheet into a workspace.
View and run SQL files¶
In Workspaces, queries are run similarly to classic Worksheets with a few small advantages, including:
Improved UI performance
Parallel execution - run two queries at the same time from the same SQL file
View multiple files or results in one layout¶
Managing multiple files with tabs and split panes offers several advantages:
Compare code or results side by side - Quickly reference one worksheet query while working on another.
Multitask more efficiently - View different cells, outputs, or files at once with less back and forth navigation.
To adjust your Workspaces layout, select vertical ellipsis (more actions) in the Workspaces pane and choose the appropriate option:
Split right
Split down
Close others
Integrate with a Git repository¶
Workspaces can be local to Snowflake, or you can sync workspaces in development with a branch in a Git repository. In Workspaces, you can:
Create a new branch, switch branches, or fetch a remote branch.
Pull the latest changes from your Git repository into your workspace.
Commit and push updated files back to your Git repository.
View and resolve any conflicts directly in Workspaces.
Create a Git workspace¶
You can create a workspace connected to a Git repository to develop and manage files directly in Snowsight.
To create a new Git-synced workspace:
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
In the Workspaces menu, select From Git repository.
Copy the URL from your Git repository (for example,
https://www.github.com/my-user/my-repo-name
), and then paste it into the Repository URL field.Optional: Rename the new Git-synced workspace.
In the API Integration menu, select an API integration.
API integrations are created by the account administrator and must allow access to the Git repository URL you are using in step 4. For details, see Create an API integration for interacting with the repository API.
In addition, if you’re using GitHub as your Git provider and prefer OAuth for authentication, the account administrator must create an API integration that supports OAuth. For example:
CREATE OR REPLACE API INTEGRATION api_integration_name API_PROVIDER = git_https_api API_ALLOWED_PREFIXES = ('https://github.com/') API_USER_AUTHENTICATION = ( type = snowflake_github_app ) ENABLED = true;
Under API integration, select an authentication method:
OAuth2 - Select Sign in to authenticate with your GitHub repository. After signing in, you won’t need to provide credentials in future sessions. Note that OAuth2 is not available for PrivateLink environments.
Personal access token - Select the database and schema where the object containing your token is stored. To create a new secret, select + Secret and enter the required details. The API integration must be configured to allow access to this secret or to all secrets.
Public repository - Select this option if you are using a public repository that doesn’t require authentication. Note that it isn’t possible to commit and push any changes from your workspace to this public repository.
Select Create.
Create a new branch¶
You can create a new branch from your current branch to work on changes independently.
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
Select the Changes tab.
Select the repository dropdown.
Select + New.
Specify a new branch name, and then select Create.
Switch to a different branch¶
If you have saved but uncommitted changes, you’ll need to choose how to handle them before switching branches.
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
In the Git workspace view, select Changes.
From the branch menu, select the branch you want to switch to.
Tip: To filter the list, start typing a branch name.
Fetch remote branches¶
If a new branch was created outside of Snowsight (for example, one created in your Git provider), you can fetch it into your Git-synced workspace using the Fetch All option. This updates your list of available remote branches.
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
In the Git workspace view, select Changes.
Select the down arrow next to the Pull menu, and then select Fetch All. When the fetch finishes, newly created remote branches appear in the branch list and are available to check out.
View updated files¶
To view all the files that were added, deleted, or modified since your last successful commit and push:
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
At the top of the folder view, select Changes. Modified files are indicated with an M, added files are indicated with an A, and deleted files are indicated with a D.
To view a visual diff of the changes in the editor, select a file.
Commit and push updates¶
After reviewing your changes, you can commit and push them to your remote Git repository from within the workspace.
To commit and push your updated files to the remote Git repository:
Sign in to Snowsight.
In the navigation menu, select Projects » Workspaces.
Select Changes at the top of the folder view.
Write a commit message in the Commit message field.
Select Push.
Write a commit message and select Push to push your updates to the Git repository.
Note
If conflicts are detected, you are prompted to pull first. Select Pull to review a list of files with conflicts.
View and resolve conflicts¶
If a conflict occurs during a push, you can view and resolve it directly in the workspace before committing again.
In Workspaces, at the top of the folder view, select Changes. If one or more files have a conflict, a message is displayed at the top of the view. Files with a conflict are indicated with a red M.
To view a visual diff of the conflict in the editor, select a file. Under File with conflicts, differences are highlighted inline.
Accept the current change, an incoming change, or both changes. The result of the merge is shown.
Under Diff View you can view the current and remote versions side by side.
Select Accept all current or Accept all remote.
After you resolve the conflicts, select Push.
Write a commit message.
Select Push.
Keyboard shortcuts¶
Worksheets provide keyboard shortcuts to help you quickly navigate, customize your view, and edit queries. The following table identifies commonly used keyboard shortcuts:
Task |
MacOS shortcut |
Windows shortcut |
---|---|---|
Run selected |
CMD + Return |
CTRL + Enter |
Run all |
CMD + Shift + Return |
CTRL + Alt + Enter |
Split pane horizontally |
CTRL + \ |
CTRL + \ |
Split pane vertically |
CTRL + / |
CTRL + / |
Limitations¶
Workspaces does not support sharing.
Query filters are not supported. Any queries containing filters will fail.
Workspaces files are not displayed on the Snowsight homepage.
Opening and editing the same worksheet in the (new) Workspaces UI and (classic) Worksheets UI simultaneously can result in lost changes.
For worksheets, execution context settings (role, warehouse, and namespace) are not synchronized across the new Workspaces UI and the classic Worksheets UI.