Snowflake CLI: Unleashing the Power of Command-Line Interface

Anurag Gupta Tomasz Urbaszek Paweł Job

The Command Line Interface (CLI) is a fundamental and indispensable tool for developers, continuing to play a central role in DevOps by providing dev productivity & CI/CD automation. Today, we’re excited to announce that Snowflake CLI is officially released in Private Preview for our customers, with support for Snowpark, Streamlit, and Snowpark Container Services workloads.

Snowflake CLI is an open-source command-line interface explicitly designed for developer-centric workloads on Snowflake in addition to SQL operations. It is a flexible and extensible tool that can accommodate modern development practices and technologies.

With Snowflake CLI, developers can create, manage, update, and view apps running on Snowflake across workloads such as Streamlit, Snowflake Container Services, or Snowpark. It supports a range of Snowflake features, including user-defined functions, stored procedures, Streamlit, and SQL execution.

Key benefits

  • Comprehensive Workload Support: Snowflake CLI accommodates various workloads, including Streamlit, Snowpark Container Services, and Snowpark. It provides a unified interface for managing and interacting with applications across these workloads, streamlining your development process.
  • Application Management: With Snowflake CLI, you can create, update, manage, and view applications running on Snowflake. Whether you’re developing interactive Streamlit apps or deploying containerized applications, Snowflake CLI provides the necessary tools to simplify application management tasks.
  • Flexibility and Extensibility: Snowflake CLI is designed to be open-sourced and extensible, allowing you to integrate it with your preferred tools, libraries, or frameworks. This flexibility enables you to tailor the CLI to your specific needs and leverage additional functionalities for enhanced productivity.
  • Developer-Centric Approach: Snowflake CLI is built with developers in mind. It embraces modern development practices and technologies, providing a command-line interface that aligns with developer workflows and enables efficient collaboration within teams.
  • Seamless SQL Execution: Snowflake CLI allows you to execute SQL queries directly from the command line. This enables quick and efficient data exploration, analysis, and manipulation, providing you with the flexibility and power of Snowflake’s SQL capabilities at your fingertips.

Snowflake CLI empowers you to take control of your data and applications, offering a powerful command-line interface for all your workload needs. Whether you’re executing SQL queries, managing applications, or exploring new data insights, Snowflake CLI enhances your productivity and enables you to unleash the full potential of Snowflake’s cloud data platform.

What does Snowflake CLI do?

Currently, using SnowCLI, you can perform multiple operations. Those include:

  • interacting with the stage and its contents
  • deploying and executing Snowpark functions and procedures
  • managing Streamlit applications
  • managing Snowpark compute pools and containers.

Let’s take a look at a few examples

  • List the contents of a stage:
snow --format=json stage list TEST         
[ { "name": "test/hellofunction/app.zip", "size": 7040, "md5": "a1a61090bf20a8b64bb7519142563864", "last_modified": "Tue, 20 Jun 2023 10:20:04 GMT" }]
  • Creating a Snowpark procedure. SnowCLI can help you not only to deploy local artifacts to Snowflake, but it will also resolve Python dependencies that have to be uploaded additionally.
snow snowpark procedure create 
--check-anaconda-for-pypi-deps
--environment="dev" \
--name="helloFunction" \
-h "app.hello" -i "()" -r "string" -f "app.zip"
  • Once you create a procedure you can execute it:
snow --format json snowpark procedure execute -p "example.public.helloFunction()"
[
{
"HELLOFUNCTION": "Hello World!"
}
]
  • Create a Streamlit app and then deploy it
$ snow streamlit create --file="streamlit.py" my_app
  • Create a Snowpark compute pool and Service
$snow snowpark cp create --name="pool-1" --num=2 --family="STANDARD_1"

$ snow snowpark services create --name="job-1" –-compute_pool="pool-1" –-spec_path= "/some-dir/spec_file.yaml"

Getting started with Snowflake CLI

To start using SnowCLI, you can install it either with pip or with homebrew (if you’re on MacOS).

Installation with pip (requires Python >= 3.8):

pip install snowflake-cli-labs

Installation with homebrew:

brew tap Snowflake-Labs/snowcli
brew install snowcli

Of course, you can also build and install the tool from the source. The most recent instructions can be found in the docs.

Once you install SnowCLI, you can verify your installation by executing the following:

snow - help

It should give you an overview of commands which you can use. Some commands are gathered in groups, like “snow snowpark” group. Others are available directly from the top level, like “snow sql”. Every group and every command allows you to get information about its usage by using the “ — help” flag.

After confirmation of successful installation by seeing the help view, you can configure connection to your Snowflake account and start using SnowCLI. To do it, the simplest option is to use the following command:

snow connection add

You will be prompted to provide some details of your new connection:

Name for this connection: <connection-name>
Snowflake account: <account-name>
Snowflake username: <username>
Snowflake password: <password>

You can also configure your connection manually in the config file. More information about this way can be found in our documentation.

Being here, you are ready to start your work with SnowCLI.

Automating CI/CD with SnowCLI

Snowflake CLI can be seamlessly integrated into CI/CD pipelines to streamline data management and automate Snowflake-related changes. By using SnowCLI in your CI/CD process, you can define Snowflake infrastructure as code, automate deployments, perform testing and validation, collaborate with version control, and integrate with other CI/CD tools. This integration enables consistent and efficient deployment of Snowflake resources, ensures data integrity, and enhances the overall efficiency of your CI/CD workflows. Check data pipeline quickstart for more details.

SnowCLI aims to be the main Snowflake command line tool across all workloads. It will be an irreplaceable help for day-to-day interaction with Snowflake but also for building CI/CD pipelines. In Snowflake, we are working continuously to improve the developer experience of our customers. By wrapping complex processes like deploying Streamlit applications or Snowpark containers into command-line scripts, we abstract the complexity so you don’t have to worry about details.

Whats Next

As Snowflake expands into the preferred application platform for Data Cloud , the SnowCLI will become an inseparable dev tool for working with Streamlit , Native Apps & Snowpark for a great developer experience. We will be adding support for Native Apps in the next iteration, along with adding a extensible plugin architecture to help our developers/partners easily extend and build on SnowCLI . We will also add backward compatibility for SnowSQL so our SnowSQL users can move easily to SnowCLI .

Get started today!

Sign up for the SnowCLI Private Preview using this form and check the docs here .

We value your feedback, and its plays a vital role in shaping the future of Snowflake CLI. We encourage you to share your thoughts, suggestions, and feature requests on Github or reach out to us at developers@snowflake.com.

Happy command-lining!

--

--