Skip to content

Commit

Permalink
Query table_comments without unrolling with UNION ALL
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 3177f04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20231003-161428.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Query table_comments without unrolling with UNION ALL
time: 2023-10-03T16:14:28.238801+02:00
custom:
Author: findepi
Issue: ""
PR: "357"
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 3177f04

Please sign in to comment.