From d293ac18f21d1bdf81b06565c7e36e6a19bc4f3b Mon Sep 17 00:00:00 2001 From: Christophe Oudar Date: Sat, 19 Oct 2024 22:56:52 +0200 Subject: [PATCH] clean 'No datasets found in the project list' log --- .../unreleased/Under the Hood-20241019-225638.yaml | 6 ++++++ .../information_schema_constraint_column_usage.sql | 9 +++------ .../tables/information_schema_key_column_usage.sql | 11 ++++------- .../google/tables/information_schema_partitions.sql | 7 ++----- 4 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20241019-225638.yaml diff --git a/.changes/unreleased/Under the Hood-20241019-225638.yaml b/.changes/unreleased/Under the Hood-20241019-225638.yaml new file mode 100644 index 0000000..48c06e8 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241019-225638.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: clean "No datasets found in the project list" log +time: 2024-10-19T22:56:38.765209+02:00 +custom: + Author: Kayrnt + Issue: "35" diff --git a/models/base/google/tables/information_schema_constraint_column_usage.sql b/models/base/google/tables/information_schema_constraint_column_usage.sql index c254c27..3003bb9 100644 --- a/models/base/google/tables/information_schema_constraint_column_usage.sql +++ b/models/base/google/tables/information_schema_constraint_column_usage.sql @@ -1,6 +1,6 @@ {# More details about base table in https://cloud.google.com/bigquery/docs/information-schema-constraint-column-usage -#} - - + + {% set preflight_sql -%} {% if project_list()|length > 0 -%} {% for project in project_list() -%} @@ -17,9 +17,6 @@ {%- endset %} {% set results = run_query(preflight_sql) %} {% set dataset_list = results | map(attribute='SCHEMA_NAME') | list %} - {%- if dataset_list | length == 0 -%} - {{ log("No datasets found in the project list", info=True) }} - {%- endif -%} WITH base AS ( {%- if dataset_list | length == 0 -%} @@ -39,7 +36,7 @@ constraint_name {% if not loop.last %}UNION ALL{% endif %} {% endfor %} {%- endif -%} - + ) diff --git a/models/base/google/tables/information_schema_key_column_usage.sql b/models/base/google/tables/information_schema_key_column_usage.sql index ceeceec..00794e1 100644 --- a/models/base/google/tables/information_schema_key_column_usage.sql +++ b/models/base/google/tables/information_schema_key_column_usage.sql @@ -1,6 +1,6 @@ {# More details about base table in https://cloud.google.com/bigquery/docs/information-schema-key-column-usage -#} - - + + {% set preflight_sql -%} {% if project_list()|length > 0 -%} {% for project in project_list() -%} @@ -17,10 +17,7 @@ {%- endset %} {% set results = run_query(preflight_sql) %} {% set dataset_list = results | map(attribute='SCHEMA_NAME') | list %} - {%- if dataset_list | length == 0 -%} - {{ log("No datasets found in the project list", info=True) }} - {%- endif -%} - + WITH base AS ( {%- if dataset_list | length == 0 -%} SELECT CAST(NULL AS STRING) AS constraint_catalog, CAST(NULL AS STRING) AS constraint_schema, CAST(NULL AS STRING) AS constraint_name, CAST(NULL AS STRING) AS table_catalog, CAST(NULL AS STRING) AS table_schema, CAST(NULL AS STRING) AS table_name, CAST(NULL AS STRING) AS column_name, CAST(NULL AS INT64) AS ordinal_position, CAST(NULL AS INT64) AS position_in_unique_constraint @@ -41,7 +38,7 @@ position_in_unique_constraint {% if not loop.last %}UNION ALL{% endif %} {% endfor %} {%- endif -%} - + ) diff --git a/models/base/google/tables/information_schema_partitions.sql b/models/base/google/tables/information_schema_partitions.sql index e816325..5193f0a 100644 --- a/models/base/google/tables/information_schema_partitions.sql +++ b/models/base/google/tables/information_schema_partitions.sql @@ -12,7 +12,7 @@ roles/bigquery.dataViewer For more information about BigQuery permissions, see Access control with IAM. -#} - + {% set preflight_sql -%} {% if project_list()|length > 0 -%} {% for project in project_list() -%} @@ -29,9 +29,6 @@ Access control with IAM. -#} {%- endset %} {% set results = run_query(preflight_sql) %} {% set dataset_list = results | map(attribute='SCHEMA_NAME') | list %} - {%- if dataset_list | length == 0 -%} - {{ log("No datasets found in the project list", info=True) }} - {%- endif -%} WITH base AS ( {%- if dataset_list | length == 0 -%} @@ -52,7 +49,7 @@ storage_tier {% if not loop.last %}UNION ALL{% endif %} {% endfor %} {%- endif -%} - + )