From ec4ecb30d1f0fa2123e81f2facaaa0982d792f82 Mon Sep 17 00:00:00 2001 From: reptillicus Date: Wed, 29 Nov 2023 17:08:16 -0600 Subject: [PATCH] Fixes #641 by using the svv_mv_info view which is queryable (#647) * Hopefully fixes #641 by using the svv_mv_info view which is queryable in redshift-serverless * Changelog entry * Explain rationale in a comment to reduce possibility of an accidental reversion --------- Co-authored-by: Doug Beatty Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Co-authored-by: colin-rogers-dbt <111200756+colin-rogers-dbt@users.noreply.github.com> (cherry picked from commit 058a3ffa2aff4b556d495667912ce50028da9cd0) --- .changes/unreleased/Fixes-20231026-164623.yaml | 6 ++++++ .../macros/relations/materialized_view/describe.sql | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixes-20231026-164623.yaml diff --git a/.changes/unreleased/Fixes-20231026-164623.yaml b/.changes/unreleased/Fixes-20231026-164623.yaml new file mode 100644 index 000000000..f06eff381 --- /dev/null +++ b/.changes/unreleased/Fixes-20231026-164623.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix describe_materialized_view for Redshift Serverless +time: 2023-10-26T16:46:23.253837-06:00 +custom: + Author: reptillicus + Issue: "641" diff --git a/dbt/include/redshift/macros/relations/materialized_view/describe.sql b/dbt/include/redshift/macros/relations/materialized_view/describe.sql index 5a8213068..a56d0756e 100644 --- a/dbt/include/redshift/macros/relations/materialized_view/describe.sql +++ b/dbt/include/redshift/macros/relations/materialized_view/describe.sql @@ -13,9 +13,10 @@ tb.sortkey1, mv.autorefresh from svv_table_info tb - left join stv_mv_info mv - on mv.db_name = tb.database - and mv.schema = tb.schema + -- svv_mv_info is queryable by Redshift Serverless, but stv_mv_info is not + left join svv_mv_info mv + on mv.database_name = tb.database + and mv.schema_name = tb.schema and mv.name = tb.table where tb.table ilike '{{ relation.identifier }}' and tb.schema ilike '{{ relation.schema }}'