|
| 1 | +import os |
1 | 2 | import pytest |
2 | 3 | from tests.fixtures.profiles import unique_schema, dbt_profile_data |
3 | 4 |
|
|
8 | 9 | get_connection |
9 | 10 | ) |
10 | 11 |
|
| 12 | +DREMIO_EDITION = os.getenv("DREMIO_EDITION") |
| 13 | + |
11 | 14 | schema_prevent_yml = """ |
12 | 15 | version: 2 |
13 | 16 | models: |
@@ -231,3 +234,55 @@ def test_overwrite_table(self, project): |
231 | 234 | assert columns_view[0].name == "table_column" |
232 | 235 | assert len(columns_table) == 1 |
233 | 236 | assert columns_table[0].name == "table_column" |
| 237 | + |
| 238 | +class TestTwinStrategyNotAppliedDremio: |
| 239 | + @pytest.fixture(scope="class") |
| 240 | + def unique_schema(self, request, prefix) -> str: |
| 241 | + test_file = request.module.__name__ |
| 242 | + # We only want the last part of the name |
| 243 | + test_file = test_file.split(".")[-1] |
| 244 | + unique_schema = f"{test_file}" |
| 245 | + return unique_schema |
| 246 | + |
| 247 | + @pytest.fixture(scope="class") |
| 248 | + def models(self): |
| 249 | + return { |
| 250 | + "schema.yml": schema_allow_yml, |
| 251 | + "view_model.sql": view_model_sql, |
| 252 | + "table_model.sql": table_model_sql, |
| 253 | + } |
| 254 | + |
| 255 | + @pytest.fixture(scope="class") |
| 256 | + def dbt_profile_data( |
| 257 | + self, unique_schema, dbt_profile_target, profiles_config_update |
| 258 | + ): |
| 259 | + profile = { |
| 260 | + "test": { |
| 261 | + "outputs": { |
| 262 | + "default": {}, |
| 263 | + }, |
| 264 | + "target": "default", |
| 265 | + }, |
| 266 | + } |
| 267 | + target = dbt_profile_target |
| 268 | + # For enterprise catalog: object_storage_source == dremio_space AND object_storage_path == dremio_space_folder |
| 269 | + # This maps to: target.datalake == target.database AND target.root_path == target.schema |
| 270 | + enterprise_catalog_name = os.getenv("DREMIO_ENTERPRISE_CATALOG") |
| 271 | + target["schema"] = unique_schema |
| 272 | + target["root_path"] = unique_schema # Make object_storage_path == dremio_space_folder |
| 273 | + target["datalake"] = enterprise_catalog_name # Set object_storage_source to enterprise catalog |
| 274 | + target["database"] = enterprise_catalog_name # Set dremio_space to same enterprise catalog |
| 275 | + |
| 276 | + profile["test"]["outputs"]["default"] = target |
| 277 | + if profiles_config_update: |
| 278 | + profile.update(profiles_config_update) |
| 279 | + return profile |
| 280 | + |
| 281 | + @pytest.mark.skipif(DREMIO_EDITION == "community", reason="Enterprise catalog is only supported in Dremio EE/DC editions.") |
| 282 | + def test_twin_strategy_not_applied_with_enterprise_catalog(self, project, caplog): |
| 283 | + # Run with twin_strategy configured but enterprise catalog enabled |
| 284 | + # Should show warning and not apply twin strategy |
| 285 | + run_dbt(["run"]) |
| 286 | + |
| 287 | + # Check that the warning message appears in the logs |
| 288 | + assert "WARNING: Twin strategy not applied - using enterprise catalog" in caplog |
0 commit comments