Skip to content

Commit

Permalink
Support overwriting tables and views with materialized views
Browse files Browse the repository at this point in the history
  • Loading branch information
damian3031 committed Jul 24, 2023
1 parent ff5cb7b commit bcd1faf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230724-214636.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Support overwriting tables and views with materialized views in Postgres adapter
time: 2023-07-24T21:46:36.297007+02:00
custom:
Author: damian3031
Issue: "8194"
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{- get_create_materialized_view_as_sql(intermediate_relation, sql) -}}

{% if existing_relation is not none %}
alter materialized view {{ existing_relation }} rename to {{ backup_relation.include(database=False, schema=False) }};
alter {{ existing_relation.type|replace("_", " ") }} {{ existing_relation }} rename to {{ backup_relation.include(database=False, schema=False) }};
{% endif %}

alter materialized view {{ intermediate_relation }} rename to {{ relation.include(database=False, schema=False) }};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,6 @@ def query_row_count(project, relation: BaseRelation) -> int:
def query_relation_type(project, relation: BaseRelation) -> Optional[str]:
return query_relation_type(project, relation)

@pytest.mark.skip(
"The current implementation does not support overwriting materialized views with tables."
)
def test_table_replaces_materialized_view(self, project, my_materialized_view):
super().test_table_replaces_materialized_view(project, my_materialized_view)

@pytest.mark.skip(
"The current implementation does not support overwriting materialized views with views."
)
def test_view_replaces_materialized_view(self, project, my_materialized_view):
super().test_view_replaces_materialized_view(project, my_materialized_view)

@pytest.mark.skip(
"The current implementation does not support overwriting tables with materialized views."
)
def test_materialized_view_replaces_table(self, project, my_table):
super().test_materialized_view_replaces_table(project, my_table)

@pytest.mark.skip(
"The current implementation does not support overwriting views with materialized views."
)
def test_materialized_view_replaces_view(self, project, my_view):
super().test_materialized_view_replaces_view(project, my_view)


class PostgresMaterializedViewChanges(MaterializedViewChanges):
@pytest.fixture(scope="class", autouse=True)
Expand Down

0 comments on commit bcd1faf

Please sign in to comment.