From 7389335e922227b9a7e59fb762592bc7bf4cb05a Mon Sep 17 00:00:00 2001 From: Itamar Hartstein Date: Thu, 26 Oct 2023 18:45:35 +0300 Subject: [PATCH] get_resources_columns: bugfix - handle backwards --- .../dbt_project/macros/base_queries/resources.sql | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/elementary/monitor/dbt_project/macros/base_queries/resources.sql b/elementary/monitor/dbt_project/macros/base_queries/resources.sql index da8e78dcd..5751e1e84 100644 --- a/elementary/monitor/dbt_project/macros/base_queries/resources.sql +++ b/elementary/monitor/dbt_project/macros/base_queries/resources.sql @@ -91,19 +91,22 @@ {% macro get_resources_columns() %} - {% set resources_columns_query %} - with information_schema_columns as ( - select * from {{ ref('elementary', 'information_schema_columns') }} - ) + {% set columns_relation = ref('elementary', 'enriched_columns') %} + {% set column_name_field = 'name' %} + {% if not elementary.relation_exists(columns_relation) %} + {% set columns_relation = ref('elementary', 'dbt_columns') %} + {% set column_name_field = 'column_name' %} + {% endif %} + {% set resources_columns_query %} select full_table_name, database_name, schema_name, table_name, - column_name, + {{ column_name_field }} as column_name, data_type - from information_schema_columns + from {{ columns_relation }} {% endset %} {% set columns_agate = run_query(resources_columns_query) %} {% set columns = elementary.agate_to_dicts(columns_agate) %}