-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support materialized view replacement
- Loading branch information
Showing
3 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Features | ||
body: Support Materialized view replacement | ||
time: 2023-03-04T00:27:08.158991+01:00 | ||
custom: | ||
Author: mdesmet | ||
Issue: "" | ||
PR: "256" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/functional/adapter/materialization/test_materialized_view.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
from dbt.tests.util import check_relation_types, run_dbt | ||
|
||
|
||
@pytest.mark.iceberg | ||
class TestIcebergMaterializedViewExists: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return { | ||
"name": "materializedview", | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_view.sql": "select 1 a", | ||
"my_table.sql": """ {{ | ||
config(materialized='table') | ||
}} | ||
select 1 a""", | ||
} | ||
|
||
def test_mv_is_dropped_when_model_runs_view(self, project): | ||
project.adapter.execute("CREATE OR REPLACE MATERIALIZED VIEW my_view AS SELECT 2 b") | ||
project.adapter.execute("CREATE OR REPLACE MATERIALIZED VIEW my_table AS SELECT 2 b") | ||
|
||
# check relation types | ||
expected = { | ||
"my_table": "materializedview", | ||
"my_view": "materializedview", | ||
} | ||
check_relation_types(project.adapter, expected) | ||
|
||
model_count = len(run_dbt(["run"])) | ||
assert model_count == 2 | ||
|
||
# check relation types | ||
expected = { | ||
"my_view": "view", | ||
"my_table": "table", | ||
} | ||
check_relation_types(project.adapter, expected) |