| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 28a02a5 commit 863b4d4
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2226,7 +2226,7 @@ def engine_adapters(self) -> t.Dict[str, EngineAdapter]: | |||
| 2226 | 2226 | ||
| 2227 | 2227 | @cached_property | |
| 2228 | 2228 | def default_catalog_per_gateway(self) -> t.Dict[str, str]: | |
| 2229 | - """Returns the catalogs for each engine adapter in a multi virtual layer setup when the catalog isn't shared.""" | ||
| 2229 | + """Returns the default catalogs for each engine adapter.""" | ||
| 2230 | 2230 | if self._default_catalog_per_gateway is None: | |
| 2231 | 2231 | self._default_catalog_per_gateway = { | |
| 2232 | 2232 | name: adapter.default_catalog | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,6 +270,8 @@ def create_no_diff(cls, environment: str, state_reader: StateReader) -> ContextD | |||
| 270 | 270 | previous_requirements=env.requirements, | |
| 271 | 271 | requirements=env.requirements, | |
| 272 | 272 | previous_environment_statements=[], | |
| 273 | + previous_gateway_managed_virtual_layer=env.gateway_managed, | ||
| 274 | + gateway_managed_virtual_layer=env.gateway_managed, | ||
| 273 | 275 | ) | |
| 274 | 276 | ||
| 275 | 277 | @property | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -239,6 +239,7 @@ def promote( | |||
| 239 | 239 | ) | |
| 240 | 240 | tables_by_gateway[gateway].append(table) | |
| 241 | 241 | ||
| 242 | + # A schema can be shared across multiple engines, so we need to group by gateway | ||
| 242 | 243 | for gateway, tables in tables_by_gateway.items(): | |
| 243 | 244 | self._create_schemas(tables=tables, gateway=gateway) | |
| 244 | 245 | ||
@@ -337,6 +338,7 @@ def _get_data_objects( | |||
| 337 | 338 | ||
| 338 | 339 | with self.concurrent_context(): | |
| 339 | 340 | existing_objects: t.Set[str] = set() | |
| 341 | + # A schema can be shared across multiple engines, so we need to group tables by both gateway and schema | ||
| 340 | 342 | for gateway, tables_by_schema in tables_by_gateway_and_schema.items(): | |
| 341 | 343 | objs_for_gateway = { | |
| 342 | 344 | obj | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -327,21 +327,15 @@ def test_evaluate_limit(): | |||
| 327 | 327 | def test_gateway_specific_adapters(copy_to_temp_path, mocker): | |
| 328 | 328 | path = copy_to_temp_path("examples/sushi") | |
| 329 | 329 | ctx = Context(paths=path, config="isolated_systems_config", gateway="prod") | |
| 330 | - assert len(ctx._engine_adapters) == 1 | ||
| 330 | + assert len(ctx._engine_adapters) == 3 | ||
| 331 | 331 | assert ctx.engine_adapter == ctx._engine_adapters["prod"] | |
| 332 | - | ||
| 333 | - with pytest.raises(SQLMeshError): | ||
| 334 | - assert ctx._get_engine_adapter("non_existing") | ||
| 335 | - | ||
| 336 | - # This will create the requested engine adapter | ||
| 337 | 332 | assert ctx._get_engine_adapter("dev") == ctx._engine_adapters["dev"] | |
| 338 | 333 | ||
| 339 | 334 | ctx = Context(paths=path, config="isolated_systems_config") | |
| 340 | - assert len(ctx._engine_adapters) == 1 | ||
| 335 | + assert len(ctx._engine_adapters) == 3 | ||
| 341 | 336 | assert ctx.engine_adapter == ctx._engine_adapters["dev"] | |
| 342 | 337 | ||
| 343 | 338 | ctx = Context(paths=path, config="isolated_systems_config") | |
| 344 | - | ||
| 345 | 339 | assert len(ctx.engine_adapters) == 3 | |
| 346 | 340 | assert ctx.engine_adapter == ctx._get_engine_adapter() | |
| 347 | 341 | assert ctx._get_engine_adapter("test") == ctx._engine_adapters["test"] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | import pytest | |
| 12 | 12 | from pathlib import Path | |
| 13 | 13 | import os | |
| 14 | + from sqlmesh.utils.concurrency import NodeExecutionFailedError | ||
| 14 | 15 | import time_machine | |
| 15 | 16 | from pytest_mock.plugin import MockerFixture | |
| 16 | 17 | from sqlglot import exp | |
@@ -4497,7 +4498,7 @@ def test_multi(mocker): | |||
| 4497 | 4498 | ||
| 4498 | 4499 | @use_terminal_console | |
| 4499 | 4500 | def test_multi_virtual_layer(mocker): | |
| 4500 | - context = Context(paths=["examples/multi_virtual_layer"]) | ||
| 4501 | + context = Context(paths=["tests/fixtures/multi_virtual_layer"]) | ||
| 4501 | 4502 | ||
| 4502 | 4503 | local_db = "db.duckdb" | |
| 4503 | 4504 | if os.path.exists(local_db): | |
@@ -4569,6 +4570,20 @@ def test_multi_virtual_layer(mocker): | |||
| 4569 | 4570 | == " item_id global_one macro_one extra\n0 gateway_2 88 1 c" | |
| 4570 | 4571 | ) | |
| 4571 | 4572 | ||
| 4573 | + # Changing the flag should show a diff | ||
| 4574 | + context.gateway_managed_virtual_layer = False | ||
| 4575 | + plan = context.plan_builder().build() | ||
| 4576 | + assert not plan.requires_backfill | ||
| 4577 | + assert ( | ||
| 4578 | + plan.context_diff.previous_gateway_managed_virtual_layer | ||
| 4579 | + != plan.context_diff.gateway_managed_virtual_layer | ||
| 4580 | + ) | ||
| 4581 | + assert plan.context_diff.has_changes | ||
| 4582 | + | ||
| 4583 | + # This should error since the default_gateway won't have access to create the view on a non-shared catalog | ||
| 4584 | + with pytest.raises(NodeExecutionFailedError, match=r"Execution failed for node SnapshotId*"): | ||
| 4585 | + context.apply(plan) | ||
| 4586 | + | ||
| 4572 | 4587 | if os.path.exists(local_db): | |
| 4573 | 4588 | os.remove(local_db) | |
| 4574 | 4589 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments