From 03ce3e837800c3426242d6461442f01849bcfc3c Mon Sep 17 00:00:00 2001 From: erikzaadi Date: Sun, 11 Feb 2024 11:33:33 +0200 Subject: [PATCH] Ensure that enriched exposures still works if cli views have not been synced --- .../enriched_exposures/enriched_exposures.sql | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/elementary/monitor/dbt_project/models/enriched_exposures/enriched_exposures.sql b/elementary/monitor/dbt_project/models/enriched_exposures/enriched_exposures.sql index a387d6328..52ff16325 100644 --- a/elementary/monitor/dbt_project/models/enriched_exposures/enriched_exposures.sql +++ b/elementary/monitor/dbt_project/models/enriched_exposures/enriched_exposures.sql @@ -7,7 +7,9 @@ config( }} {% set dbt_exposures_relation = ref('dbt_exposures') %} -{% set depends_on_columns_column_exists = elementary.column_exists_in_relation(dbt_exposures_relation, 'depends_on_columns') %} +{% set elementary_exposures_relation = ref('elementary_cli', 'elementary_exposures') %} +{% set depends_on_columns_column_exists_on_dbt_exposures = elementary.column_exists_in_relation(dbt_exposures_relation, 'depends_on_columns') %} +{% set depends_on_columns_column_exists_on_elementary_exposures = elementary.column_exists_in_relation(elementary_exposures_relation, 'depends_on_columns') %} select COALESCE(ee.unique_id, de.unique_id) as unique_id, @@ -29,10 +31,14 @@ select COALESCE(ee.metadata_hash, de.metadata_hash) as metadata_hash, COALESCE(ee.label, de.label) as label, COALESCE(ee.raw_queries, de.raw_queries) as raw_queries, -{% if depends_on_columns_column_exists %} +{% if depends_on_columns_column_exists_on_dbt_exposures and depends_on_columns_column_exists_on_elementary_exposures %} COALESCE(ee.depends_on_columns, de.depends_on_columns) as depends_on_columns -{% else %} +{% elif depends_on_columns_column_exists_on_elementary_exposures %} ee.depends_on_columns as depends_on_columns +{% elif depends_on_columns_column_exists_on_dbt_exposures %} + de.depends_on_columns as depends_on_columns +{% else %} + null as depends_on_columns {% endif %} from - {{ dbt_exposures_relation }} de full join {{ ref('elementary_cli', 'elementary_exposures') }} ee on ee.name = de.name + {{ dbt_exposures_relation }} de full join {{ elementary_exposures_relation }} ee on ee.name = de.name