Skip to content

Commit

Permalink
Update trino__get_columns_in_relation to use information_schema.columns
Browse files Browse the repository at this point in the history
  • Loading branch information
posulliv committed Nov 1, 2024
1 parent 5e6331c commit 3d38b39
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dbt/include/trino/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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) -%}

Expand All @@ -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 %}
Expand Down

0 comments on commit 3d38b39

Please sign in to comment.