dbt project name retrieval in model sql file

47 Views Asked by At

I am new to dbt. I want to retrieve dbt project name in dbt model sql file.

Ex:

SELECT '{{<project_name>}}'||'.'||'{{model.path}}' AS UPDATED_BY ;

How can I pass <project_name> here. I dont want to create a variable in dbt_project.yml file to pass project name, instead I want the project name to be coming from dbt system variables.

Thanks in Advance.

1

There are 1 best solutions below

0
Pratik Ghodke On

Unfortunately, there is no straightforward way to access the root project folder name.

In the dbt_project.yml file, there is a pre-populated name field that you can access using "project_name" in any dbt model.

# dbt_project.yml 

name: your_project <--- This one

config-version: 2
version: version

profile: profilename
...
{{ log("Project Name: " ~ project_name, info=True) }}