|
8 | 8 | BasePythonIncrementalTests, |
9 | 9 | BasePythonModelTests, |
10 | 10 | ) |
| 11 | +from tests.functional.adapter.fixtures import MaterializationV2Mixin |
11 | 12 | from tests.functional.adapter.python_model import fixtures as override_fixtures |
12 | 13 |
|
13 | 14 |
|
| 15 | +def verify_temp_tables_cleaned(project): |
| 16 | + verify_temp_table_cleaned(project, "*__dbt_stg") |
| 17 | + verify_temp_table_cleaned(project, "*__dbt_tmp") |
| 18 | + |
| 19 | + |
| 20 | +def verify_temp_table_cleaned(project, suffix): |
| 21 | + tmp_tables = project.run_sql( |
| 22 | + "SHOW TABLES IN {database}.{schema} LIKE '" + f"{suffix}'", fetch="all" |
| 23 | + ) |
| 24 | + assert len(tmp_tables) == 0 |
| 25 | + |
| 26 | + |
14 | 27 | @pytest.mark.python |
15 | 28 | @pytest.mark.skip_profile("databricks_uc_sql_endpoint") |
16 | 29 | class TestPythonModel(BasePythonModelTests): |
@@ -207,3 +220,39 @@ def test_workflow_run(self, project): |
207 | 220 | "SELECT * FROM {database}.{schema}.my_workflow_model", fetch="all" |
208 | 221 | ) |
209 | 222 | assert len(sql_results) == 10 |
| 223 | + |
| 224 | + |
| 225 | +@pytest.mark.python |
| 226 | +@pytest.mark.skip_profile("databricks_uc_sql_endpoint") |
| 227 | +class TestChangingSchemaV2(MaterializationV2Mixin): |
| 228 | + @pytest.fixture(scope="class") |
| 229 | + def models(self): |
| 230 | + return {"simple_python_model.py": override_fixtures.simple_python_model} |
| 231 | + |
| 232 | + def test_changing_unique_tmp_table_suffix(self, project): |
| 233 | + util.run_dbt(["run"]) |
| 234 | + util.write_file( |
| 235 | + override_fixtures.simple_python_model_v2, |
| 236 | + project.project_root + "/models", |
| 237 | + "simple_python_model.py", |
| 238 | + ) |
| 239 | + util.run_dbt(["run"]) |
| 240 | + verify_temp_tables_cleaned(project) |
| 241 | + |
| 242 | + |
| 243 | +@pytest.mark.python |
| 244 | +@pytest.mark.skip_profile("databricks_uc_sql_endpoint") |
| 245 | +class TestChangingSchemaIncrementalV2(MaterializationV2Mixin): |
| 246 | + @pytest.fixture(scope="class") |
| 247 | + def models(self): |
| 248 | + return {"incremental_model.py": override_fixtures.simple_incremental_python_model} |
| 249 | + |
| 250 | + def test_changing_unique_tmp_table_suffix(self, project): |
| 251 | + util.run_dbt(["run"]) |
| 252 | + util.write_file( |
| 253 | + override_fixtures.simple_incremental_python_model_v2, |
| 254 | + project.project_root + "/models", |
| 255 | + "incremental_model.py", |
| 256 | + ) |
| 257 | + util.run_dbt(["run"]) |
| 258 | + verify_temp_tables_cleaned(project) |
0 commit comments