Snowflake’s new VSCode plugin is here!
Back in February of 2021, I authored a Medium post on how to use Visual Studio Code as an IDE for Snowflake. That article quickly became my most popular post with over 15K views! It’s also become one of the more widely read posts in the entire Snowflake publication. I think that’s a great testament to the popularity of both Snowflake and VSCode.
That plugin works fairly well! Over 30K developers have downloaded it, and a new version was released just a month ago. However, it was built and released by an independent developer, so it doesn’t benefit from the Snowflake internal knowledge base, or our engineering and support teams. So as much as it pains me to say this — NEVER READ THAT ARTICLE AGAIN!! Clear it from your browser history. Delete it from your favorites. Pretend it never happened…
Because <drumroll please!> Snowflake has released our own VSCode plugin! It’s officially in Public Preview (PuPr) and available for installation from the Microsoft Visual Studio Extension marketplace. Unlike the plugin I wrote about previously, this one was developed and released by Snowflake and will have the full support of our Product Management and Engineering teams.
Feature Overview
Here are some of the key features that are available in the PuPr release:
- Accounts and Sessions: the plugin allows you to connect to and easily switch between multiple Snowflake accounts. And (this is really cool) you can share a single session between multiple open VSCode editor windows! Support for Single Sign On (SSO) is available.
- Snowflake SQL Intellisense: autocomplete for object names, keywords, and built-in functions, with signature help for function calls. Links to documentation for keywords and built-in functions on hover.
- Database Explorer: a treeview-based panel that lets you drill down into object definitions and details.
- Query Execution: not just single statements, but multiple statement executions!
- Query Results and History panel: View and sort query results and export results to CSV format. Review prior statement history and results, and copy/paste support on previous queries.
VSCode itself brings some additional benefits that don’t (yet) exist in the web-based Snowflake UI, aka Snowsight. Those include Git integration for source control, and (wait for it…) DARK MODE!
Installation
The Snowflake plugin installs like any other VSCode extension. Start VSCode, go to the Extensions Marketplace page, search for “Snowflake”, and install the one with the blue checkmark. There are quite a few extensions that have the Snowflake logo, or have Snowflake in the name. Don’t be fooled! Make sure you select the one that has the blue checkmark!
Note: if you have a prior version of this installed from the Private Preview, please uninstall that one first.
Following installation, you should see the Snowflake icon in the left-hand icon tray, as shown below. Click that to start the connection process.
Connecting to Snowflake
Clicking the Snowflake icon for the first time starts the connection wizard, and the first step is to enter your account URL. That can be a little confusing, because it’s not asking for the entire URL that you use to access your Snowflake account through the browser — just the part before the .snowflakecomputing.com.
So, if your account URL is something like https://hooli.us-east-1.snowflakecomputing.com
, then you enter hooli.us-east-1
in the Account Name/URL box.
The next step is to provide your username and password. The Snowflake extension also supports SAML-based SSO. OAuth support is still on the “to-do” list for now.
Once you’re connected, the dialog will change to allow you to set your default context for the session. You can enter your role, database, schema, and warehouse. These are all optional, as your context can be changed at any time — just as in the regular Snowsight UI. There’s also a toggle switch that enables Secondary Role authorizations within the current session.
Database Explorer
The Database Explorer is context-aware, and automatically filters the list of objects to match the current role (or any secondary roles, if selected). The Explorer is a treeview-style, but doesn’t show “empty” folders. For example, if there are no Views in the selected schema, there won’t be a Views icon showing (0)
objects. I think that makes the interface much cleaner and less “chatty”. One of the really neat features of the Database Explorer is its ability to show details for ALL Snowflake schema objects, including both internal and external Stage definitions, Streams, Tasks, and Snowpipes, as well as Tables, Views, Functions, and Procedures.
In the figure below, you can see that the Snowflake.Account_Usage
schema has 1 user-defined function and 54 views. This particular schema has no Tables, Stored Procedures, Streams, Tasks, Snowpipes, and so on. Clicking on any object will open the Details panel for that object.
Writing and Executing SQL
Browsing your database structure is cool and all, but how do you execute SQL queries? VSCode is file-based, so create a new file. Selecting File -> New File will present a dropdown list of file types to choose from, and one of those choices will be Snowflake SQL File. You can map that command to any keystroke combination you like. cmd-shift-P is the current default here. A third method is to click the “New Document” icon at the far right end of the Database Explorer bar. You can see it in the image above.
Just start typing, and Intellisense will kick in and present autocomplete options. Typing a function name will present the different options for function signatures. For any built-in function, you’ll see a full description of the function along with links to the Snowflake docs.
There are a few ways to execute queries. The >>
icon in the upper right hand corner will run every statement in the file, in sequence. There will also be a small Execute
link generated above each statement. Clicking that will run the SQL statement just below it. You can also place the cursor inside any statement and press the cmd-enter key combination. The results of the query appear in the lower panel, in the Snowflake: Query Results tab. From there, you can download the results as a CSV file.
Caveat Emptor
While this release is certainly exciting, it’s important to remember that this is still in Public Preview. There are going to be… “opportunities for enhancement”. For now, please leave any comments or questions in the Q&A section of the Marketplace page for the plugin.
Here are some other things to keep in mind as you work with the plugin.
You’re now working with VSCode .SQL files that are stored in the file system, not Snowsight worksheets stored inside Snowflake. This gives you instant integration to Git and other source control programs, but pulling the code back into Snowsight is still a manual copy/paste or “Import from SQL File” operation. There’s no automatic synchronization (yet).
This plugin is only available in the desktop version of VSCode. There’s no support for the web version.
And for those of you building applications using Snowpark, there’s no direct or special support for the Snowpark API. However, you can still use VSCode’s native integrations for Python, Java, and Scala.
Conclusion
I’m so excited to see this plugin come to fruition, because I wrote the original Jira ticket to create one back in February of 2019!
I encourage every user of both Snowflake and VSCode to find and install this plugin, and provide us feedback! We look forward to hearing from you.
Let it Snow!