From c7a36921b46884cef432143e2d78a566e738f5e0 Mon Sep 17 00:00:00 2001 From: kijewskimateusz <65126185+kijewskimateusz@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:52:22 +0200 Subject: [PATCH] Fix non-default project names not working in dbt-sql template (#1500) ## Changes Hello Team, While tinkering with your solution, I've noticed that profiles provided in dbt_project.yml and profiles.yml for generated dbt asset bundles. do not align. This led to the following error, when deploying DAB: ``` + dbt deps --target=dev 11:24:02 Running with dbt=1.8.2 11:24:02 Warning: No packages were found in packages.yml 11:24:02 Warning: No packages were found in packages.yml + dbt seed --target=dev --vars '{ dev_schema: mateusz_kijewski }' 11:24:05 Running with dbt=1.8.2 11:24:05 Encountered an error: Runtime Error Could not find profile named 'dbt_sql' ``` I have corrected profile name in profiles.yml.tmpl to the name used in dbt_project.yml.tmpl. Using the opportunity of forking your repo, I've also updated tests configuration in model config as starting of dbt v1.8 it's been raising warnings of configuration change from tests to data_tests ``` 11:31:34 [WARNING]: Deprecated functionality The `tests` config has been renamed to `data_tests`. Please see https://docs.getdbt.com/docs/build/data-tests#new-data_tests-syntax for more information. ``` ## Tests --- .../template/{{.project_name}}/dbt_profiles/profiles.yml.tmpl | 2 +- .../dbt-sql/template/{{.project_name}}/requirements-dev.txt | 2 +- .../resources/{{.project_name}}_job.yml.tmpl | 2 +- .../template/{{.project_name}}/src/models/example/schema.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/dbt_profiles/profiles.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/dbt_profiles/profiles.yml.tmpl index cce80f8d..e96931e2 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/dbt_profiles/profiles.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/dbt_profiles/profiles.yml.tmpl @@ -3,7 +3,7 @@ {{- $catalog = "\"\" # workspace default"}} {{- end}} # This file defines dbt profiles for deployed dbt jobs. -my_dbt_project: +{{.project_name}}: target: dev # default target outputs: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/requirements-dev.txt b/libs/template/templates/dbt-sql/template/{{.project_name}}/requirements-dev.txt index 10d7b9f1..e6b86120 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/requirements-dev.txt +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/requirements-dev.txt @@ -1,3 +1,3 @@ ## requirements-dev.txt: dependencies for local development. -dbt-databricks>=1.0.0,<2.0.0 +dbt-databricks>=1.8.0,<2.0.0 diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/resources/{{.project_name}}_job.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/resources/{{.project_name}}_job.yml.tmpl index acf1aa48..bad12c75 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/resources/{{.project_name}}_job.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/resources/{{.project_name}}_job.yml.tmpl @@ -35,7 +35,7 @@ resources: libraries: - pypi: - package: dbt-databricks>=1.0.0,<2.0.0 + package: dbt-databricks>=1.8.0,<2.0.0 new_cluster: spark_version: {{template "latest_lts_dbr_version"}} diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/src/models/example/schema.yml b/libs/template/templates/dbt-sql/template/{{.project_name}}/src/models/example/schema.yml index d34b9e64..c64f1bfc 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/src/models/example/schema.yml +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/src/models/example/schema.yml @@ -7,7 +7,7 @@ models: columns: - name: customer_name description: "The name of a customer" - tests: + data_tests: - unique - not_null @@ -16,6 +16,6 @@ models: columns: - name: order_date description: "The date on which orders took place" - tests: + data_tests: - unique - not_null