EXECUTE DCM PROJECT

statementdeferredContainer services & dev tooling

docs.snowflake.com ↗

Executes one of the following actions on a DCM project: - EXECUTE DCM PROJECT <name> PLAN performs a dry run of the DCM project to analyze the changes that would be applied to the target during a deployment, but doesn’t apply any changes. - EXECUTE DCM PROJECT <name> PLAN DELTA performs a faster dry run that only evaluates definitions that changed since the last deployment, and any downstream definitions that depend on them. - EXECUTE DCM PROJECT <name> DEPLOY deploys the changes defined in the project’s definition files to the account. - EXECUTE DCM PROJECT <name> TEST ALL tests all expectations from attached data metric functions managed by the DCM project. - EXECUTE DCM PROJECT <name> PREVIEW returns a data sample of the current definitions specified in the source path for the specified table, view, or dynamic table. - EXECUTE DCM PROJECT <name> PURGE drops all entities, revokes all grants, and removes all attachments currently managed by the DCM project. For PLAN and DEPLOY, you can either provide the path to the project location that has the manifest.yml file (FROM '<source_files_path>') or reuse the rendered definitions from a previous deployment (FROM DEPLOYMENT). Use FROM DEPLOYMENT to restore a previous deployment (without restoring data) or to check and remediate the account’s drift from that deployment.

Syntax

EXECUTE DCM PROJECT <name>
  PLAN [ DELTA ]
  { fromSource | fromDeployment }
  [ OUTPUT_PATH '<output_path>' ]

EXECUTE DCM PROJECT <name>
  DEPLOY [ AS "<deployment_name_alias>" ]
  { fromSource | fromDeployment }

EXECUTE DCM PROJECT <name>
  TEST ALL

EXECUTE DCM PROJECT <name>
  PREVIEW <fully_qualified_table_object_name>
  USING CONFIGURATION <config_name>
  [ ENVIRONMENT ( <bind_variable> ) ]
  FROM '<source_files_path>'
  [ LIMIT <number_of_rows> ]

EXECUTE DCM PROJECT <name>
  PURGE [ AS "<deployment_name_alias>" ]

Where

fromSource ::=
  [ USING [ CONFIGURATION <config_name> ] [ ( <expr> [ , <expr> ... ] ) ] ]
  [ ENVIRONMENT ( <bind_variable> ) ]
  FROM '<source_files_path>'

Where

fromDeployment ::=
  FROM DEPLOYMENT { <deployment_name> | "<deployment_name_alias>" | LAST | LATEST }

Parameters

NameRequiredDescription
namerequiredSpecifies the identifier for the DCM project to execute. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
PLANrequiredInstructs Snowflake to perform a dry run of the DCM project. For a dry run, Snowflake analyzes the changes that would be applied to the target during a deployment, but doesn’t apply any changes.
PLAN DELTArequiredInstructs Snowflake to perform a faster dry run that only evaluates the definitions that changed since the last deployment, and any downstream definitions in the project that depend on them. Unlike a full PLAN, PLAN DELTA doesn’t compare unchanged definitions against the current account state. Use PLAN DELTA during active development to get faster feedback on incremental changes. Because it skips unchanged definitions, it doesn’t detect changes that happened outside of DCM Projects on your account since the last deployment (for example, a view dropped or altered by another user). Always run a full PLAN before deploying to ensure no external changes will cause a deployment failure.
DEPLOY [ AS "deployment_name_alias" ]requiredDeploys the changes defined in the project’s definition files to the account; optionally specifies an alias for the deployment.
FROM ...requiredSpecifies the source of the project definitions. PREVIEW always reads from a directory of source files. For PLAN and DEPLOY, provide exactly one of the following: FROM 'source_files_path': Reads the source files for the DCM project from the specified directory. The directory must contain a manifest file and at least one definition file in /sources/definitions/. The manifest file provides the templating values in case a configuration was specified. FROM DEPLOYMENT: Reuses the rendered definitions from a previous deployment, instead of reading source files from a directory. Use this to restore a previous deployment (without restoring data) or to check and remediate the account’s drift from that deployment. Identify the deployment with one of the following: deployment_name: The deployment’s generated name, in the form DEPLOYMENT$<num>. "deployment_name_alias": The alias set by the AS clause, enclosed in double quotes. LAST or LATEST: The most recent deployment of the DCM project, of any status. These keywords are synonyms. They don’t skip failed or incomplete deployments. If a deployment name and an alias match two different deployments, the deployment name takes precedence. To find the name or alias of a previous deployment, run SHOW DEPLOYMENTS IN DCM PROJECT. Using a deployment created by PURGE as the source isn’t supported. This restriction prevents accidental purges. To drop everything the DCM project manages, use PURGE. FROM DEPLOYMENT and USING are mutually exclusive because FROM DEPLOYMENT uses definitions that were already rendered.
TEST ALLrequiredPreview Feature — Open Available to all accounts. Tests all data quality expectations attached to tables, dynamic tables, or views which are currently managed by the DCM project.
PREVIEW fully_qualified_table_object_namerequiredPreview Feature — Open Available to all accounts. Returns a data sample of the current definitions specified in the source path for the specified table, view, or dynamic table - independent of any deployed state.
PURGE [ AS "deployment_name_alias" ]requiredDrops all entities, revokes all grants, and removes all attachments currently managed by the DCM project, by running a deployment with no definitions. Optionally, specify an alias for the deployment. Warning PURGE is destructive by design. Use it with caution and only for non-production projects, such as development sandboxes or demos. PURGE doesn’t drop the DCM project itself. To remove the project object after purging, run DROP DCM PROJECT. The purge execution appears in the deployment history of the DCM project, where you can confirm that the command ran successfully.
USING CONFIGURATION config_nameoptionalSpecifies the configuration to use. This lets you customize deployments for different environments, such as development, staging, or production, without using different project definition files. If the configuration name is not in all uppercase, enclose it in double quotes. This option is mutually exclusive with FROM DEPLOYMENT, which uses definitions that were already rendered.
USING ( expr [ , expr ... ] )optionalOptionally specifies template variable values. Using this option overrides any default or configuration values for this specific variable. The single expression must have the following form: <variable_name> => <variable_value>. For lists, use the following form: <variable_name> => [<value1>, <value2>, ...]. For example: wh_size => 'MEDIUM' or teams => ['TEAM_A', 'TEAM_B']. This lets you customize deployments for different environments, such as development, staging, or production, without using different project definition files. This option is mutually exclusive with FROM DEPLOYMENT, which uses definitions that were already rendered.
ENVIRONMENT ( bind_variable )optionalPreview Feature — Open Available to all accounts. Supplies the values for the environment variables and secrets that the manifest declares under templating as env_vars and env_secrets. The bind variable must contain a flat JSON object that maps each declared name to its value, for example {"BUILD_NUMBER": "482", "API_KEY": "..."}. Definition files reference the values with _snow.env_var("NAME") and _snow.env_secret("NAME"). DCM Projects masks the values of declared secrets in the PLAN and DEPLOY output, deployment history artifacts, and logs. ENVIRONMENT accepts only a bind variable, never a string literal typed into the SQL text. Use a client ? placeholder, a session variable, or a Snowflake Scripting variable. The order of the clauses is fixed. Specify USING [ CONFIGURATION <config_name> ] [ ( <expr> [ , <expr> ... ] ) ] first, then ENVIRONMENT ( <bind_variable> ), and then FROM. Any other order causes the statement to fail. For example:Copy code EXECUTE DCM PROJECT my_project PLAN USING CONFIGURATION DEV (wh_size => 'MEDIUM') ENVIRONMENT (?) FROM '@my_database.my_schema.my_stage/my_project'; ENVIRONMENT is supported on PLAN, PREVIEW, and DEPLOY. It isn’t available on TEST ALL or PURGE, because neither of those commands renders definition files. For more information, see Environment variables and secrets.
OUTPUT_PATH 'output_path'optionalSpecifies a directory where Snowflake writes the rendered project definitions and the raw changeset from a PLAN execution. If the directory doesn’t exist, Snowflake creates it. Each PLAN execution that specifies OUTPUT_PATH overwrites any previously rendered output in that directory. If the plan uses FROM DEPLOYMENT, Snowflake copies the rendered definitions from that deployment into the specified path. For more information about the contents of this directory, see The /out/ subfolder.
LIMIT number_of_rowsoptionalLimits the number of rows returned by PREVIEW.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | DCM project | OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). PLAN | DCM project | Sufficient instead of OWNERSHIP for the PLAN variant, including PLAN DELTA. PLAN runs with the privileges of the DCM project owner role. For more information, see PLAN privilege. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Output

After the DCM project executes, this command returns the following output depending on the variation: - PLAN, DEPLOY, and PURGE: A single row containing a JSON object with the change log. Because PURGE runs as an empty deployment, its output is identical to DEPLOY, with all managed entities reported as DROP. - PREVIEW: A result set. - TEST ALL: A single row containing a JSON object that contains the full response. Note For object types still in preview, the exact output format can be subject to change. The standard plan output contains the following information about the plan execution in JSON format: Property | Description version | Schema version of the output format. Version 2 is the latest and only supported version. metadata | Contextual information about the execution. metadata.timestamp | ISO 8601 timestamp of when the command was executed. metadata.query_id | Unique identifier for the query that produced this plan. metadata.project_name | Fully qualified name of the DCM Project object. metadata.user | Name of the user who executed the command. metadata.role_name | Active role used to execute the command. metadata.command | The command that was executed. PLAN or DEPLOY. changeset | An array of change entries. Each entry represents one object that would be or was created, altered, or dropped. An empty array indicates the project definitions are already in sync with the account. changeset[].type | The planned action for the object. Possible values: CREATE, ALTER, DROP. changeset[].object_id | Identifies the target object. changeset[].object_id.domain | The Snowflake object type. changeset[].object_id.name | Name of the object. changeset[].object_id.fqn | Fully qualified name of the object. changeset[].object_id.database | Database containing the object. Omitted for account-level objects. changeset[].object_id.schema | Schema containing the object. Omitted for database-level and account-level objects. changeset[].changes | An array of change descriptors detailing the specific attribute modifications. changeset[].changes[].kind | The type of change. Possible values: set, changed, unset, nested, collection. The value of kind determines the remaining keys in the object. changeset[].changes[].attribute_name | Name of the attribute being set or changed. Present when kind is set, changed, or unset. changeset[].changes[].value | The new value for the attribute. Present when kind is set or changed. changeset[].changes[].prev_value | The previous value of the attribute before the change. Present only when kind is changed. changeset[].changes[].collection_name | Name of the collection being modified (for example, columns, constraints, privileges, expectations). Present only when kind is collection. changeset[].changes[].id_label | Label used to identify items within the collection (for example, name). Present only on certain collections. changeset[].changes[].changes | A nested array of collection item descriptors. Present only when kind is collection. changeset[].changes[].changes[].kind | The type of change to the collection item. Possible values: added, removed, modified. changeset[].changes[].changes[].item_id | Identifies the item within the collection. Can be a string or an object, depending on the collection type. changeset[].changes[].changes[].changes | An array of further change descriptors for this item. Present for added and modified items. Always absent for removed items. An example of a plan output: The TEST output contains the overall status and expectations with their values in the following format: Note During the preview phase, the exact output format can be subject to change. Property | Description status | Overall result of the test run. Possible values: SUCCESSFUL (all expectations met), FAILED (one or more expectations violated). expectations[] | An array of expectation results, one for each data quality expectation evaluated. table_name | Fully qualified name of the table or view on which the expectation was evaluated. metric_database | Database that contains the data metric function. metric_schema | Schema that contains the data metric function. metric_name | Name of the data metric function (for example, NULL_COUNT, MIN, UNIQUE_COUNT). expectation_name | Name of the expectation as defined in the project. expectation_expression | Boolean expression that the metric value is evaluated against (for example, value = 0, value >= 0). value | The result of the data metric function evaluation. Present only when expectation_violated is false. expectation_violated | Whether the expectation was violated. true if the metric value did not satisfy the expectation expression; false otherwise. column_names | An array of column names on which the data metric function was evaluated. An example of the JSON output for a data quality test:

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by