ALTER DBT PROJECT

statementpartialContainer services & dev tooling

docs.snowflake.com ↗

Object: DBT PROJECT

Modifies the properties of an existing dbt project object.

Syntax

supportedpartialnot supportednot scored

ALTER DBT PROJECT [ IF EXISTS ] <name> RENAME TO <new_name>

ALTER DBT PROJECT <name> DEPLOY FROM '<source_location>'

ALTER DBT PROJECT [ IF EXISTS ] <name> SET
  [ DBT_VERSION = '<version_number>' ]
  [ DEFAULT_TARGET = '<default_target>' ]
  [ DEFAULT_ENVIRONMENT = '<environment_name>' ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [, ... ] ) ]
  [ AUTO_COMPILE = { TRUE | FALSE } ]
  [ DEFAULT_WRITEBACK = { TRUE | FALSE } ]
  [ COMMENT = '<string_literal>' ]

ALTER DBT PROJECT [ IF EXISTS ] <name> UNSET
  [ DBT_VERSION ]
  [ DEFAULT_TARGET ]
  [ DEFAULT_ENVIRONMENT ]
  [ EXTERNAL_ACCESS_INTEGRATIONS ]
  [ AUTO_COMPILE ]
  [ DEFAULT_WRITEBACK ]
  [ COMMENT ]

Parameters

NameRequiredDescription
nameSpecifies the identifier for the dbt project object to alter. 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.
RENAME TO new_nameChanges the name of the dbt project object to new_name. The new identifier must be unique for the schema. For more information about identifiers, see Identifier requirements. You can move the object to a different database and/or schema while optionally renaming the object. To do so, specify a qualified new_name value that includes the new database and/or schema name in the form db_name.schema_name.object_name or schema_name.object_name, respectively. Note The destination database and/or schema must already exist. In addition, an object with the same name cannot already exist in the new location; otherwise, the statement returns an error. Moving an object to a managed access schema is prohibited unless the object owner (that is, the role that has the OWNERSHIP privilege on the object) also owns the target schema. When an object is renamed, other objects that reference it must be updated with the new name.
DEPLOY FROM 'source_location'Deploys source files to the mutable live version of the dbt project object. The deployment replaces the contents of the live version in a single operation, including existing target artifacts. The source location must point to a directory that contains a single dbt_project.yml file at its root. The source files can be in any of the following locations: An internal named stage, for example: '@my_db.my_schema.my_internal_named_stage/path/to/dbt_projects_or_projects_parent' Internal user stages and table stages aren’t supported. A dbt workspace, for example: 'snow://workspace/user$.public."my_workspace_name"/versions/live' Workspace URIs use versions/live, which refers to the active working state of the workspace. We recommend enclosing the workspace name in double quotes because workspace names are case-sensitive and can contain special characters. An existing dbt project stage, for example: 'snow://dbt/my_db.my_schema.my_existing_dbt_project_object/versions/live' The version specifier is required and is live. A Git repository stage, for example: '@my_db.my_schema.my_git_repository_stage/branches/my_branch/path/to/dbt_project_or_projects_parent' For more information about creating and managing a Git repository object and stage, see Using a Git repository in Snowflake and CREATE GIT REPOSITORY.
SET ...Sets one or more specified properties or parameters for the dbt project object:
DBT_VERSION = 'version_number'Specifies a version for the dbt project object. If no value is specified, the system defaults to the version set by the DEFAULT_DBT_VERSION account parameter. For more information, see Set the account-level default version.
AUTO_COMPILE = { TRUE | FALSE }Specifies whether Snowflake compiles the dbt project after each deployment: TRUE: Runs dbt compile during deployment. If an external access integration is configured, Snowflake first runs dbt deps, then dbt compile. Stores the compile artifacts in the live version. FALSE: Skips both commands. You can run either command later with EXECUTE DBT PROJECT.
DEFAULT_WRITEBACK = { TRUE | FALSE }Specifies whether subsequent executions write generated target and log files back to the live version by default. You can override this value for an individual execution with the WRITEBACK parameter of EXECUTE DBT PROJECT. Snowflake stores the per-query result artifacts and archive regardless of this setting. For retrieval instructions, see Access dbt artifacts and logs programmatically.
DEFAULT_TARGET = 'default_target'Specifies the profile used for compilation and subsequent executions (for example, prod) of the dbt project object. This parameter can be overridden by using the EXECUTE DBT PROJECT command with ARGS = '--target <other_target>'.
DEFAULT_ENVIRONMENT = 'environment_name'Sets or changes the default environment used for compilation and subsequent executions of the dbt project object. The value identifies an environment defined in the project’s env.yml file. If this attribute isn’t set, Snowflake uses default_environment: from env.yml. You can override this per run with the ENVIRONMENT argument on the EXECUTE DBT PROJECT command. Use the reserved name NO_ENV to run without any environment by default. For more information, see Use SQL environment variables and private Git packages.
EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )Specifies the external access integrations used to grant permissions to pull remote dependencies from dbt package hub or GitHub. When you set this parameter and the object’s AUTO_COMPILE property is TRUE, deployment runs dbt deps before dbt compile. When AUTO_COMPILE = FALSE, deployment doesn’t run dbt deps or dbt compile, even if this parameter is set. If a dbt command that you run during execution needs network access (for example, deps), specify EXTERNAL_ACCESS_INTEGRATIONS on EXECUTE DBT PROJECT. For more information, see Understand dependencies for dbt Projects on Snowflake.
COMMENT = 'string_literal'Adds a comment or overwrites an existing comment for the dbt project object.
UNSET ...Unsets one or more specified properties or parameters for the dbt project object to NULL or no value: DBT_VERSION DEFAULT_TARGET DEFAULT_ENVIRONMENT EXTERNAL_ACCESS_INTEGRATIONS AUTO_COMPILE DEFAULT_WRITEBACK COMMENT To unset multiple properties or parameters with a single ALTER statement, separate each property or parameter with a comma. When unsetting a property or parameter, specify only the property or parameter name (unless the syntax above indicates that you should specify the value). Specifying the value returns an error.

Usage notes

Access control requirements

A role used to execute this SQL command must have at least one of the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | dbt 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). 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.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by