Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update trino__get_columns_in_relation to use information_schema.columns #440

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}'
{%- 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
Loading