From f3e606534ce1a19bb8abdfdaa448804d4bfaf73c Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Wed, 25 Oct 2023 20:33:58 -0400 Subject: [PATCH 1/3] map t/f to bool for database results --- dbt/adapters/redshift/relation_configs/materialized_view.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt/adapters/redshift/relation_configs/materialized_view.py b/dbt/adapters/redshift/relation_configs/materialized_view.py index 1c6fb229a..44e18e3ac 100644 --- a/dbt/adapters/redshift/relation_configs/materialized_view.py +++ b/dbt/adapters/redshift/relation_configs/materialized_view.py @@ -182,10 +182,14 @@ def parse_relation_results(cls, relation_results: RelationResults) -> dict: "mv_name": materialized_view.get("table"), "schema_name": materialized_view.get("schema"), "database_name": materialized_view.get("database"), - "autorefresh": materialized_view.get("autorefresh"), "query": cls._parse_query(query.get("definition")), } + autorefresh_value = materialized_view.get("autorefresh") + if autorefresh_value is not None: + bool_filter = {"t": True, "f": False} + config_dict["autorefresh"] = bool_filter.get(autorefresh_value, autorefresh_value) + # the default for materialized views differs from the default for diststyle in general # only set it if we got a value if materialized_view.get("diststyle"): From cc3b488aa9057db5fcb0023b515776ea8dbf6621 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Wed, 25 Oct 2023 20:34:36 -0400 Subject: [PATCH 2/3] remove unnecessary test that did not properly test its hypothesis --- .../test_materialized_views.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/functional/adapter/materialized_view_tests/test_materialized_views.py b/tests/functional/adapter/materialized_view_tests/test_materialized_views.py index cf7d433c7..d2bf1cda4 100644 --- a/tests/functional/adapter/materialized_view_tests/test_materialized_views.py +++ b/tests/functional/adapter/materialized_view_tests/test_materialized_views.py @@ -163,19 +163,6 @@ def test_change_is_applied_via_alter_str_true(self, project, my_materialized_vie assert_message_in_logs(f"Applying ALTER to: {my_materialized_view}", logs) assert_message_in_logs(f"Applying REPLACE to: {my_materialized_view}", logs, False) - def test_change_is_applied_via_alter_str_false(self, project, my_materialized_view): - self.check_start_state(project, my_materialized_view) - - self.change_config_via_alter_str_false(project, my_materialized_view) - _, logs = run_dbt_and_capture_with_retries_redshift_mv( - ["--debug", "run", "--models", my_materialized_view.name] - ) - - self.check_state_alter_change_is_applied_str_false(project, my_materialized_view) - - assert_message_in_logs(f"Applying ALTER to: {my_materialized_view}", logs) - assert_message_in_logs(f"Applying REPLACE to: {my_materialized_view}", logs, False) - def test_change_is_applied_via_replace(self, project, my_materialized_view): self.check_start_state(project, my_materialized_view) From 610771aa0a3bea9e8ce7ead6b6f7283cbed4390e Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Wed, 25 Oct 2023 20:37:46 -0400 Subject: [PATCH 3/3] changelog --- .changes/unreleased/Fixes-20231025-203732.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20231025-203732.yaml diff --git a/.changes/unreleased/Fixes-20231025-203732.yaml b/.changes/unreleased/Fixes-20231025-203732.yaml new file mode 100644 index 000000000..9e6bf1af7 --- /dev/null +++ b/.changes/unreleased/Fixes-20231025-203732.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix parsing of database results for materialized view auto refresh +time: 2023-10-25T20:37:32.191259-04:00 +custom: + Author: mikealfare + Issue: "643"