From 57b3b80d02bb52293fe25a0b3b53a65ab2d4e346 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Tue, 3 Oct 2023 16:11:52 +0200 Subject: [PATCH] Query table_comments without unrolling `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. --- dbt/include/trino/macros/catalog.sql | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dbt/include/trino/macros/catalog.sql b/dbt/include/trino/macros/catalog.sql index 8e1bd296..1cc51595 100644 --- a/dbt/include/trino/macros/catalog.sql +++ b/dbt/include/trino/macros/catalog.sql @@ -38,7 +38,6 @@ ), table_comment as ( - {%- for schema in schemas %} select catalog_name as "table_database", schema_name as "table_schema", @@ -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