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 #444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20241105-083613.yaml
Original file line number Diff line number Diff line change
@@ -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"
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
Loading