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.

Comment les objets du projet dbt sont mis à jour

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.

Pour créer un pipeline de production, nous vous recommandons de créer un objet de projet dbt et de planifier son exécution avec une tâche. Comme chaque version d’objet d’un projet dbt est immuable, cela garantit qu’aucun changement ne sera apporté entre les exécutions, à moins que quelqu’un n’ajoute explicitement une nouvelle version.

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 vous permet d’ajouter une version ; sans celle-ci, ce serait l’équivalent de l’exécution de CREATE DBT PROJECT sur un objet déjà créé, ce qui échouerait.

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