Managing DCM projects using Snowflake CLI¶
You can manage a DCM project using Snowflake CLI. For more information about DCM projects, see Snowflake DCM Projects.
Install Snowflake CLI with DCM project features¶
To use the snow dcm commands, you must install Snowflake CLI version 3.16.0 or later. For more information, see Installing Snowflake CLI.
Verify you have a valid connection to Snowflake¶
Snowflake CLI requires a working connection to interact with Snowflake. For information about managing connections, see Configuring Snowflake CLI.
Enable DCM commands in Snowflake CLI¶
To use DCM commands, you must enable the SNOWFLAKE_CLI_FEATURES_ENABLE_SNOWFLAKE_PROJECTS feature flag, using either of the following methods:
Set the
SNOWFLAKE_CLI_FEATURES_ENABLE_SNOWFLAKE_PROJECTSenvironment variable totruebefore running the command.Set the
enable_snowflake_projectsconfiguration option totruein theconfig.tomlfile, as shown in the following example:
Initialize a DCM project from a template¶
To initialize a DCM project from a template, use the
snow initcommand:where
<project_dir_name>is the directory with the DCM project files. This directory is created by thesnow initcommand and is populated with the project files generated from the specified template.For example, the following command creates the project files in the
MY_PROJECTdirectory:
Snowflake CLI commands¶
To support DCM Projects, Snowflake CLI added the following commands:
Create and deploy DCM projects¶
This section describes how to create, validate, and deploy DCM projects using Snowflake CLI.
Create a DCM project¶
Use the snow dcm create command to create a new DCM project in Snowflake. The project identifier can be specified directly as an argument or resolved from the manifest.yml file.
Create a project using the identifier from the default target specified in the manifest :
Create a project using the identifier from the
devtarget specified in the manifest:Create a project only if it does not already exist:
For more information, see snow dcm create.
Plan a DCM project¶
Use the snow dcm plan command to validate your project before deploying. This command shows what changes would be applied without actually making any modifications.
Validate a project:
Validate with variable substitution:
Validate using a specific target profile and save the output:
When using
--save-output, the command saves the response and artifacts to a localout/directory.
For more information, see snow dcm plan.
Deploy a DCM project¶
Use the snow dcm deploy command to apply changes defined in your DCM project to Snowflake..
Deploy a project:
Deploy with variable substitution:
Deploy with an alias for the deployment:
Deploy from a specific directory using a target profile:
For more information, see snow dcm deploy.
Preview a DCM project¶
Use the snow dcm preview command to return rows from any table, view, or dynamic table defined in your project. This command is useful for testing your definitions before or after deployment.
Preview data from a table:
Preview with a row limit:
Preview with variable substitution:
For more information, see snow dcm preview.
Test a DCM project¶
Use the snow dcm test command to run all expectations (data metric functions) defined in your project. This command validates data quality rules and returns pass/fail results.
Test a project:
Test using a target profile:
Test and save the results:
The command returns exit code 0 if all tests pass, or exit code 1 if any test fails.
For more information, see snow dcm test.
Refresh a DCM project¶
Use the snow dcm refresh command to refresh all dynamic tables defined in your DCM project. This triggers an immediate refresh of the data.
Refresh dynamic tables in a project:
Refresh using a target profile:
Refresh and save the output:
The command reports the status of each dynamic table, including the number of rows inserted and deleted.
For more information, see snow dcm refresh.
Drop a DCM project¶
Use the snow dcm drop command to drop a DCM project. This command deletes the project and all its versions. The stage associated with the project is not deleted.
Drop a project:
Drop a project only if it exists:
For more information, see snow dcm drop.
Manage deployed DCM projects¶
After deploying a DCM project, you can list and manage individual deployments.
List deployed DCM projects¶
Use the snow dcm list-deployments command to list all deployments of a given DCM project.
List deployments for a project:
List deployments using a target profile:
The output shows the deployment name and alias (if set) for each deployment.
For more information, see snow dcm list-deployments.
Drop deployed DCM projects¶
Use the snow dcm drop-deployment command to drop a specific deployment from a DCM project.
Drop a deployment by name:
Note
For deployment names containing
$, use single quotes to prevent shell expansion.Drop a deployment by alias:
Drop a deployment only if it exists:
For more information, see snow dcm drop-deployment.