Skip to content

Commit d8a2dfc

Browse files
author
Kostiantyn Liepieshov
authored
use pg_catalog.svv_columns to load columns info (#89)
To support redshift external tables and late binding views we need additionally pull info from pg_catalog.svv_columns. Ref: https://github.com/dbt-labs/dbt-redshift/blob/fe91015ac6361c48531b439ac72d3f477d9cc07b/dbt/include/redshift/macros/adapters.sql
1 parent 186f398 commit d8a2dfc

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

macros/meta/information_schema.sql

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,43 @@
1717
{% macro redshift__get_monitored_columns(table_schema, db_name) %}
1818

1919
{%- call statement('columns', fetch_result=True) -%}
20+
with bound_views as (
21+
select
22+
table_name,
23+
table_schema,
24+
table_catalog,
25+
column_name,
26+
data_type,
27+
is_nullable
28+
from
29+
{% if db_name %}{{db_name}}.{% endif %} information_schema.columns
30+
),
31+
external_views as (
32+
select
33+
table_name,
34+
table_schema,
35+
table_catalog,
36+
column_name,
37+
data_type,
38+
is_nullable
39+
from
40+
pg_catalog.svv_columns
41+
),
42+
unioned as (
43+
select * from bound_views
44+
union all
45+
select * from external_views
46+
)
47+
2048
select
49+
column_name,
50+
data_type,
2151
table_name,
2252
table_schema,
2353
table_catalog,
24-
column_name,
25-
data_type,
2654
is_nullable
27-
from
28-
{% if db_name %}{{db_name}}.{% endif %}information_schema.columns
55+
from
56+
unioned
2957
where
3058
table_schema = '{{ table_schema }}'
3159
{% endcall %}

0 commit comments

Comments
 (0)