Skip to content

Commit

Permalink
Query table_comments without unrolling
Browse files Browse the repository at this point in the history
`table_comments` is equally "hard" for the engine as
`information_schema.columns`. Avoid optimizing the query on the `dbt`
side by sending `UNION ALL` with individual schemas. Let the engine
figure out the optimal strategy.
  • Loading branch information
findepi committed Oct 3, 2023
1 parent 6d4cc2a commit 57b3b80
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions dbt/include/trino/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
),

table_comment as (
{%- for schema in schemas %}
select
catalog_name as "table_database",
schema_name as "table_schema",
Expand All @@ -51,11 +50,7 @@
and
schema_name != 'information_schema'
and
schema_name = '{{ schema | lower }}'
{% if not loop.last %}
union all
{% endif %}
{%- endfor %}
table_schema in ('{{ schemas | join("','") | lower }}')
)

select
Expand Down

0 comments on commit 57b3b80

Please sign in to comment.