From 64648067c5ba8131b8a3f42df7476a87c8b1cd11 Mon Sep 17 00:00:00 2001 From: Itamar Hartstein Date: Wed, 8 May 2024 18:24:27 +0300 Subject: [PATCH] remove refs to information_schema_columns --- .gitignore | 1 + .../macros/base_queries/resources.sql | 29 ------------------- .../table_timestamp_columns.sql | 2 +- .../test_recommendations.sql | 2 +- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 68d6a278b..0bcf7fb72 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/elementary/monitor/dbt_project/macros/base_queries/resources.sql b/elementary/monitor/dbt_project/macros/base_queries/resources.sql index 0ba95c2eb..d0d819eec 100644 --- a/elementary/monitor/dbt_project/macros/base_queries/resources.sql +++ b/elementary/monitor/dbt_project/macros/base_queries/resources.sql @@ -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 %} diff --git a/elementary/monitor/dbt_project/models/tests_recommendation/table_timestamp_columns.sql b/elementary/monitor/dbt_project/models/tests_recommendation/table_timestamp_columns.sql index 76e8c6e84..5d9a3647e 100644 --- a/elementary/monitor/dbt_project/models/tests_recommendation/table_timestamp_columns.sql +++ b/elementary/monitor/dbt_project/models/tests_recommendation/table_timestamp_columns.sql @@ -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. diff --git a/elementary/monitor/dbt_project/models/tests_recommendation/test_recommendations.sql b/elementary/monitor/dbt_project/models/tests_recommendation/test_recommendations.sql index 919ce0b70..3007fd991 100644 --- a/elementary/monitor/dbt_project/models/tests_recommendation/test_recommendations.sql +++ b/elementary/monitor/dbt_project/models/tests_recommendation/test_recommendations.sql @@ -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 ),