Skip to content

Commit d70ad84

Browse files
committed
Twin strategy tests
1 parent 9d3c7b0 commit d70ad84

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

tests/functional/adapter/dremio_specific/test_twin_strategy.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import pytest
23
from tests.fixtures.profiles import unique_schema, dbt_profile_data
34

@@ -8,6 +9,8 @@
89
get_connection
910
)
1011

12+
DREMIO_EDITION = os.getenv("DREMIO_EDITION")
13+
1114
schema_prevent_yml = """
1215
version: 2
1316
models:
@@ -231,3 +234,55 @@ def test_overwrite_table(self, project):
231234
assert columns_view[0].name == "table_column"
232235
assert len(columns_table) == 1
233236
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

Comments
 (0)