Understand dbt project objects

A DBT PROJECT is a schema-level object that contains versioned source files for your dbt project in Snowflake. You can connect a dbt project object to a workspace, or you can create and manage the object independently of a workspace.

A dbt project object is typically based on a dbt project directory that contains a dbt_project.yml file. This is the pattern that Snowflake uses when you deploy (create) a dbt project object from within a workspace.

dbt project objects support role-based access control (RBAC). You can CREATE, ALTER, and DROP dbt project objects like other schema-level objects in Snowflake. You can use the EXECUTE DBT PROJECT command from a Snowflake warehouse to execute dbt commands like test and run. You can also use tasks to schedule execution of these commands.

dbtプロジェクトオブジェクトの更新方法

dbt project objects don't automatically update as you edit the workspace. You must execute ALTER DBT PROJECT ... ADD VERSION each time you want to redeploy and update the files of the dbt project object.

プロダクションパイプラインを作成するには、dbtプロジェクトオブジェクトを作成して、 タスクで実行をスケジュールする ことをお勧めします。各dbtプロジェクトオブジェクトのバージョンは不変であるため、そうすることで、誰かが明示的に新しいバージョンを追加しない限り、実行間で変更がないことを保証できます。

To update the dbt project object's files, you must add a new version in a workspace, for example:

ALTER DBT PROJECT testdbt.public.my_dbt_project_object
  ADD VERSION FROM 'snow://workspace/user$.public."all_my_dbt_projects"/versions/last';

If your dbt project object is backed by Git and you want to automate your testing and deployment, run the Snow CLI snow dbt deploy command with the --force option, as shown in the following example:

snow dbt deploy --source 'snow://workspace/user$.public."all_my_dbt_projects"/versions/last'  --force my_dbt_project;

--force を使用するとバージョンを追加できます。これを指定しない場合、すでに作成されたオブジェクトに対して CREATE DBT PROJECT を実行するのと同じになるため、失敗します。

For more information about versioning, see Versions for dbt project objects and files.