Setup, Functions, & Limitations of Project Dependencies in dbt Developer Hub

Published
May 22, 2024
Author

What are project dependencies in dbt?

Project dependencies in dbt are utilized to establish cross-project references and include non-private dbt packages in a project's dependencies. They are set up using Dependencies.yml. Private packages are not supported due to their inability to support Jinja rendering or conditional configuration.

  • Project dependencies: These are the links between different projects, allowing one to reference and use elements from another. They are crucial for maintaining order and structure in a project.
  • Non-private dbt packages: These are dbt packages that are publicly available and can be included in a project's dependencies. They differ from private packages, which are not supported.
  • Jinja rendering: This is a feature that private packages do not support. It's a template engine for Python, allowing for dynamic content creation.

How to set up project dependencies in dbt?

To set up project dependencies, ensure that dbt v1.6 or higher is being used. Define the upstream project in dependencies.yml with a name that matches the "name" in its "dbt_project.yml". Also, ensure the upstream project has a successful production run.

  • dbt v1.6 or higher: This is the minimum version of dbt required to set up project dependencies.
  • Upstream project: This is the project that your current project depends on. It needs to be defined in the dependencies.yml file.
  • Successful production run: This is a requirement for the upstream project. It ensures that the project is functioning correctly before it is used as a dependency.

What is the role of the ref function in dbt project dependencies?

The ref function in dbt plays a crucial role in inferring dependencies and ensuring that models are built in the correct order. It also ensures that the current model selects from upstream tables and views in the same environment.

  • Ref function: This function is used to reference models from the upstream project. It helps dbt infer dependencies and build models in the correct order.
  • Upstream tables and views: These are the tables and views from the upstream project that the current model selects from. They need to be in the same environment.

What does it mean that project dependencies in dbt are acyclic?

Project dependencies in dbt are acyclic, meaning they only move in one direction and prevent ref cycles, or loops, that can cause issues with data workflows. For instance, if project B depends on project A, a new model in project A cannot import and use a public model from project B.

  • Acyclic dependencies: These are dependencies that only move in one direction, preventing loops or ref cycles that can disrupt data workflows.
  • Ref cycles: These are loops created when a project depends on itself, either directly or indirectly. Acyclic dependencies prevent these.

What are the limitations of project dependencies in dbt?

One of the limitations of project dependencies in dbt is that they do not support private packages because they do not support Jinja rendering or conditional configuration. Additionally, project dependencies are acyclic, which means a new model in an upstream project cannot import and use a public model from a downstream project.

  • Private packages: These are not supported in dbt project dependencies due to their lack of support for Jinja rendering and conditional configuration.
  • Acyclic limitation: This refers to the inability of a new model in an upstream project to import and use a public model from a downstream project.

Keep reading

See all