You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has a downside that now it's much more difficult to determine which table corresponds to which model by just looking at the database with a SQL client. However, the table names have a predictable length so there are no longer any surprises with identfiers exceeding the max length at the physical layer.
540
540
541
+
#### Virtual Data Environment Modes
542
+
543
+
By default, Virtual Data Environments (VDE) are applied across both development and production environments. This allows SQLMesh to reuse physical tables when appropriate, even when promoting from development to production.
544
+
545
+
However, users may prefer their production environment to be non-virtual. The non-exhaustive list of reasons may include:
546
+
547
+
- Integration with third-party tools and platforms, such as data catalogs, may not work well with the virtual view layer that SQLMesh imposes by default
548
+
- A desire to rely on time travel features provided by cloud data warehouses such as BigQuery, Snowflake, and Databricks
549
+
550
+
To mitigate this, SQLMesh offers an alternative 'dev-only' mode for using VDE. It can be enabled in the project configuration like so:
551
+
552
+
=== "YAML"
553
+
554
+
```yaml linenums="1"
555
+
virtual_environment_mode: dev_only
556
+
```
557
+
558
+
=== "Python"
559
+
560
+
```python linenums="1"
561
+
from sqlmesh.core.config import Config
562
+
563
+
config = Config(
564
+
virtual_environment_mode="dev_only",
565
+
)
566
+
```
567
+
568
+
'dev-only' mode means that VDE is applied only in development environments. While in production, model tables and views are updated directly and bypass the virtual layer. This also means that physical tables in production will be created using the original, **unversioned** model names. Users will still benefit from VDE and data reuse across development environments.
569
+
570
+
Please note the following tradeoffs when enabling this mode:
571
+
572
+
- All data inserted in development environments is used only for [preview](../concepts/plans.md#data-preview-for-forward-only-changes) and will **not** be reused in production
573
+
- Reverting a model to a previous version will be applied going forward and may require an explicit data restatement
574
+
575
+
!!! warning
576
+
Switching the mode for an existing project will result in a **complete rebuild** of all models in the project. Refer to the [Table Migration Guide](./table_migration.md) to migrate existing tables without rebuilding them from scratch.
577
+
578
+
541
579
#### Environment view catalogs
542
580
543
581
By default, SQLMesh creates an environment view in the same [catalog](../concepts/glossary.md#catalog) as the physical table the view points to. The physical table's catalog is determined by either the catalog specified in the model name or the default catalog defined in the connection.
Copy file name to clipboardExpand all lines: docs/reference/configuration.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,7 @@ Configuration options for how SQLMesh manages environment creation and promotion
46
46
| `environment_suffix_target` | Whether SQLMesh views should append their environment name to the `schema`, `table` or `catalog` - [additional details](../guides/configuration.md#view-schema-override). (Default: `schema`) | string | N |
47
47
| `gateway_managed_virtual_layer` | Whether SQLMesh views of the virtual layer will be created by the default gateway or model specified gateways - [additional details](../guides/multi_engine.md#gateway-managed-virtual-layer). (Default: False) | boolean | N |
48
48
| `environment_catalog_mapping` | A mapping from regular expressions to catalog names. The catalog name is used to determine the target catalog for a given environment. | dict[string, string] | N |
49
+
| `virtual_environment_mode` | Determines the Virtual Data Environment (VDE) mode. If set to `full`, VDE is used in both production and development environments. The `dev_only` option enables VDE only in development environments, while in production, no virtual layer is used and models are materialized directly using their original names (i.e., no versioned physical tables). (Default: `full`) | string | N |
Copy file name to clipboardExpand all lines: sqlmesh/core/config/root.py
+14-7Lines changed: 14 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,11 @@
14
14
from sqlmesh.cicd.config import CICDBotConfig
15
15
from sqlmesh.core import constants as c
16
16
from sqlmesh.core.console import get_console
17
-
from sqlmesh.core.config import EnvironmentSuffixTarget, TableNamingConvention
17
+
from sqlmesh.core.config.common import (
18
+
EnvironmentSuffixTarget,
19
+
TableNamingConvention,
20
+
VirtualEnvironmentMode,
21
+
)
18
22
from sqlmesh.core.config.base import BaseConfig, UpdateStrategy
19
23
from sqlmesh.core.config.common import variables_validator, compile_regex_mapping
20
24
from sqlmesh.core.config.connection import (
@@ -110,6 +114,7 @@ class Config(BaseConfig):
110
114
physical_schema_mapping: A mapping from regular expressions to names of schemas in which physical tables for corresponding models will be placed.
111
115
environment_suffix_target: Indicates whether to append the environment name to the schema or table name.
112
116
physical_table_naming_convention: Indicates how tables should be named at the physical layer
117
+
virtual_environment_mode: Indicates how environments should be handled.
113
118
gateway_managed_virtual_layer: Whether the models' views in the virtual layer are created by the model-specific gateway rather than the default gateway.
114
119
infer_python_dependencies: Whether to statically analyze Python code to automatically infer Python package requirements.
115
120
environment_catalog_mapping: A mapping from regular expressions to catalog names. The catalog name is used to determine the target catalog for a given environment.
0 commit comments