Skip to content

Commit

Permalink
remove refs to information_schema_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
haritamar committed May 8, 2024
1 parent 7cc9b23 commit 6464806
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var/
logs/
.venv
poetry.lock
package-lock.yml

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
29 changes: 0 additions & 29 deletions elementary/monitor/dbt_project/macros/base_queries/resources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,3 @@
{% set resources_meta_agate = run_query(resources_meta_query) %}
{% do return(elementary.agate_to_dicts(resources_meta_agate)) %}
{% endmacro %}


{% macro get_resources_columns() %}
{% set columns_relation = ref('elementary', 'information_schema_columns') %}
{% if not elementary.relation_exists(columns_relation) %}
{% set columns_relation = ref('elementary', 'dbt_columns') %}
{% endif %}

{% set resources_columns_query %}
select
full_table_name,
database_name,
schema_name,
table_name,
column_name,
data_type
from {{ columns_relation }}
{% endset %}
{% set columns_agate = run_query(resources_columns_query) %}
{% set columns = elementary.agate_to_dicts(columns_agate) %}
{% set resources_columns_map = {} %}
{% for column in columns %}
{% set resource = column.get('full_table_name') %}
{% set resource_columns = resources_columns_map.get(resource, []) %}
{% do resource_columns.append({'column': column.get('column_name'), 'type': column.get('data_type')}) %}
{% do resources_columns_map.update({resource: resource_columns}) %}
{% endfor %}
{% do return(resources_columns_map) %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ with
lower(schema_name) as schema_name,
lower(table_name) as table_name,
lower(column_name) as column_name
from {{ ref("elementary", "information_schema_columns") }}
from {{ elementary.get_elementary_relation('information_schema_columns') }}
),

-- Inferring the timestamp column based on their names and assigning a confidence score.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ with
lower(schema_name) as schema_name,
lower(table_name) as table_name,
json_agg(json_build_object('name', lower(column_name), 'data_type', lower(data_type))) as columns
from {{ ref("elementary", "information_schema_columns") }}
from {{ elementary.get_elementary_relation('information_schema_columns') }}
group by 1, 2, 3
),

Expand Down

0 comments on commit 6464806

Please sign in to comment.