Skip to content

Commit

Permalink
Merge pull request #1246 from elementary-data/ele-1927-backwards-bugf…
Browse files Browse the repository at this point in the history
…ix-for-test-management-api

get_resources_columns: bugfix - handle backwards
  • Loading branch information
haritamar authored Oct 26, 2023
2 parents e36220d + 7389335 commit 5358b96
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions elementary/monitor/dbt_project/macros/base_queries/resources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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) %}
Expand Down

0 comments on commit 5358b96

Please sign in to comment.