CREATE DBT PROJECT

statementsupportedContainer services & dev tooling

docs.snowflake.com ↗

Object: DBT PROJECT

Creates a new dbt project object or replaces an existing dbt project object. This command deploys the project files to versions/live. Warning CREATE OR REPLACE DBT PROJECT recreates the object and may remove its run history. To update the files of an existing dbt project object, use ALTER DBT PROJECT ... DEPLOY instead.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] DBT PROJECT [ IF NOT EXISTS ] <name>
  FROM '<source_location>'
  [ 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>' ]

Parameters

NameRequiredDescription
nameString that specifies the name of the dbt project object. Must be unique within the schema in which the dbt project object is created. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
FROM 'source_location'Required. A string that specifies the location of the dbt project source files. The source location must point to a directory that contains a single dbt_project.yml file at its root. Although workspaces support working with repositories that contain multiple dbt projects, you must select a specific project directory when deploying a dbt project object. The dbt project object source files can be in any one 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.
COMMENT = 'string_literal'Specifies a comment for the dbt project object. Default: No value
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 deploying the source files: 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: TRUE
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: TRUE
DEFAULT_TARGET = 'default_target'Specifies the profile used for compilation and subsequent executions (for example, prod) of the dbt project object. You can override this parameter by using the EXECUTE DBT PROJECT command with ARGS = '--target <other_target>'. Default: No value
DEFAULT_ENVIRONMENT = 'environment_name'Specifies 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. Default: No value For more information, see Use SQL environment variables and private Git packages.
EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )Specifies the external access integration used to grant permissions to pull remote dependencies from dbt package hub or GitHub. When you set this parameter and AUTO_COMPILE = TRUE (the default), 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.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object CREATE DBT PROJECT | Schema 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.

See also

Referenced by