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 authored and hovaesco committed Nov 29, 2023
1 parent 2e0cd58 commit 22720e3
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 @@ -67,7 +67,6 @@


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


Expand Down

0 comments on commit 22720e3

Please sign in to comment.