From 42687955cf692a4b8477f305b99d5cb9a0ab7176 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Mon, 1 Jul 2024 14:57:19 -0700 Subject: [PATCH] Fix ORA-12098: cannot comment on the materialized view --- dbt/include/oracle/macros/adapters.sql | 4 ++++ dbt_adbs_test_project/models/sales_internet_mv.sql | 2 +- dbt_adbs_test_project/models/schema.yml | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dbt/include/oracle/macros/adapters.sql b/dbt/include/oracle/macros/adapters.sql index 1048127..6d3b8af 100644 --- a/dbt/include/oracle/macros/adapters.sql +++ b/dbt/include/oracle/macros/adapters.sql @@ -260,8 +260,12 @@ {% macro oracle__alter_relation_comment(relation, comment) %} {% set escaped_comment = oracle_escape_comment(comment) %} + {% if relation.type == 'materialized_view' %} + comment on materialized view {{ relation }} is {{ escaped_comment }} + {% else %} {# "comment on table" even for views #} comment on table {{ relation }} is {{ escaped_comment }} + {% endif %} {% endmacro %} {% macro oracle__persist_docs(relation, model, for_relation, for_columns) -%} diff --git a/dbt_adbs_test_project/models/sales_internet_mv.sql b/dbt_adbs_test_project/models/sales_internet_mv.sql index b8be090..244f86b 100644 --- a/dbt_adbs_test_project/models/sales_internet_mv.sql +++ b/dbt_adbs_test_project/models/sales_internet_mv.sql @@ -13,6 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. #} -{{ config(materialized='materialized_view')}} +{{ config(materialized='materialized_view', persist_docs={"relation": true, "columns": true}) }} select * from {{ source('sh_database', 'sales') }} where channel_id = 5 diff --git a/dbt_adbs_test_project/models/schema.yml b/dbt_adbs_test_project/models/schema.yml index 9f3d26e..2a577d0 100644 --- a/dbt_adbs_test_project/models/schema.yml +++ b/dbt_adbs_test_project/models/schema.yml @@ -22,6 +22,9 @@ sources: - name: costs models: + - name: sales_internet_mv + description: Test comment for Materialized View + - name: kafka description: kafka_description config: