From 56505eeb871bc19b7edd7f3a3bf5e110e145119f Mon Sep 17 00:00:00 2001 From: Padraig O'Sullivan Date: Thu, 31 Oct 2024 15:38:55 -0400 Subject: [PATCH] Update trino__get_columns_in_relation to use information_schema.columns --- .changes/unreleased/Under the Hood-20241105-083613.yaml | 7 +++++++ dbt/include/trino/macros/adapters.sql | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20241105-083613.yaml diff --git a/.changes/unreleased/Under the Hood-20241105-083613.yaml b/.changes/unreleased/Under the Hood-20241105-083613.yaml new file mode 100644 index 00000000..10e10729 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241105-083613.yaml @@ -0,0 +1,7 @@ +kind: Under the Hood +body: Update trino__get_columns_in_relation to use information_schema.columns +time: 2024-11-05T08:36:13.788945-05:00 +custom: + Author: posulliv + Issue: "443" + PR: "444" diff --git a/dbt/include/trino/macros/adapters.sql b/dbt/include/trino/macros/adapters.sql index 8a5c7757..6d02f5b4 100644 --- a/dbt/include/trino/macros/adapters.sql +++ b/dbt/include/trino/macros/adapters.sql @@ -5,7 +5,12 @@ {% macro trino__get_columns_in_relation(relation) -%} {%- set sql -%} - describe {{ relation }} + select column_name, data_type + from {{ relation.information_schema() }}.columns + where + table_catalog = '{{ relation.database | lower }}' + and table_schema = '{{ relation.schema | lower }}' + and table_name = '{{ relation.identifier | lower}}' {%- endset -%} {%- set result = run_query(sql) -%} @@ -20,7 +25,7 @@ {% set columns = [] %} {% for row in result %} - {% do columns.append(api.Column.from_description(row['Column'].lower(), row['Type'])) %} + {% do columns.append(api.Column.from_description(row['column_name'].lower(), row['data_type'])) %} {% endfor %} {% do return(columns) %} {% endmacro %}