From f35fdb7a69bb53b85c66020f65d7cc00b547d436 Mon Sep 17 00:00:00 2001 From: Christophe Oudar Date: Mon, 6 Jan 2025 15:32:16 +0100 Subject: [PATCH] DBT_BQ_MONITORING_GCP_PROJECTS shouldn't be required --- .changes/unreleased/Fixes-20250106-153152.yaml | 6 ++++++ dbt_project.yml | 2 +- macros/project_list.sql | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Fixes-20250106-153152.yaml diff --git a/.changes/unreleased/Fixes-20250106-153152.yaml b/.changes/unreleased/Fixes-20250106-153152.yaml new file mode 100644 index 0000000..4a84fc8 --- /dev/null +++ b/.changes/unreleased/Fixes-20250106-153152.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix DBT_BQ_MONITORING_GCP_PROJECTS being required while it should not for region mode +time: 2025-01-06T15:31:52.975763+01:00 +custom: + Author: Kayrnt + Issue: "" diff --git a/dbt_project.yml b/dbt_project.yml index ca0394e..f96b590 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -30,7 +30,7 @@ models: vars: # Environment configuration bq_region: "{{ env_var('DBT_BQ_MONITORING_REGION', 'us') }}" - input_gcp_projects: "{{ env_var('DBT_BQ_MONITORING_GCP_PROJECTS') }}" # example: ['my-gcp-project', 'my-gcp-project2'] + input_gcp_projects: "{{ env_var('DBT_BQ_MONITORING_GCP_PROJECTS', '') }}" # example: ['my-gcp-project', 'my-gcp-project2'] # https://cloud.google.com/bigquery/pricing#pricing # On-demand compute (analysis) pricing use_flat_pricing: "{{ env_var('DBT_BQ_MONITORING_USE_FLAT_PRICING', true) }}" diff --git a/macros/project_list.sql b/macros/project_list.sql index 02ee9bb..03a6271 100644 --- a/macros/project_list.sql +++ b/macros/project_list.sql @@ -5,9 +5,13 @@ {{ return(projects) }} {#-- check if it's the string and it contains a "," --#} {% elif projects is string %} - {% set projects_replaced = projects | replace("'", '"') %} - {% set json = fromjson('{"v":' ~ projects_replaced ~ '}') %} - {{ return (json['v']) }} + {% if projects == '' %} + {{ return([]) }} + {% else %} + {% set projects_replaced = projects | replace("'", '"') %} + {% set json = fromjson('{"v":' ~ projects_replaced ~ '}') %} + {{ return (json['v']) }} + {% endif %} {% else %} {{ exceptions.raise_compiler_error('Invalid `input_gcp_projects` variables. Got: ' ~ input_gcp_projects ~ ' but expected form like input_gcp_projects = ["project_1", "project_2"] ') }} {% endif %}