Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sqlmesh/cli/project_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sqlmesh.integrations.dlt import generate_dlt_models_and_settings
from sqlmesh.utils.date import yesterday_ds
from sqlmesh.utils.errors import SQLMeshError
from sqlmesh.core.config.common import VirtualEnvironmentMode

from sqlmesh.core.config.common import DBT_PROJECT_FILENAME
from sqlmesh.core.config.connection import (
Expand Down Expand Up @@ -114,7 +115,13 @@ def _gen_config(
- ambiguousorinvalidcolumn
- invalidselectstarexpansion
""",
ProjectTemplate.DBT: f"""# --- Model Defaults ---
ProjectTemplate.DBT: f"""# --- Virtual Data Environment Mode ---
# Enable Virtual Data Environments (VDE) for *development* environments.
# Note that the production environment in dbt projects is not virtual by default to maintain compatibility with existing tooling.
# https://sqlmesh.readthedocs.io/en/stable/guides/configuration/#virtual-data-environment-modes
virtual_environment_mode: {VirtualEnvironmentMode.DEV_ONLY.lower()}

# --- Model Defaults ---
# https://sqlmesh.readthedocs.io/en/stable/reference/model_configuration/#model-defaults
model_defaults:
start: {start or yesterday_ds()}
Expand Down
1 change: 0 additions & 1 deletion sqlmesh_dbt/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def run(self, select: t.Optional[str] = None, full_refresh: bool = False) -> Non

self.context.plan(
select_models=select_models,
no_auto_categorization=True, # everything is breaking / foward-only
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing a test to fail / throw up a Enter the effective date (eg. '1 year', '2020-01-01') to apply forward-only changes retroactively message, even though no_prompts=True.

The sqlmesh_dbt plan args arent quite right anyway, so ive removed it for now

run=True,
no_diff=True,
no_prompts=True,
Expand Down
9 changes: 9 additions & 0 deletions tests/cli/test_project_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from sqlmesh.utils.errors import SQLMeshError
from sqlmesh.cli.project_init import init_example_project, ProjectTemplate
from sqlmesh.utils import yaml
from sqlmesh.core.context import Context
from sqlmesh.core.config.common import VirtualEnvironmentMode


def test_project_init_dbt(tmp_path: Path):
Expand All @@ -22,3 +24,10 @@ def test_project_init_dbt(tmp_path: Path):
sqlmesh_config = next(f for f in files if f.name == "sqlmesh.yaml")
assert "model_defaults" in sqlmesh_config.read_text()
assert "start: " in sqlmesh_config.read_text()

with (tmp_path / "profiles.yml").open("w") as f:
yaml.dump({"jaffle_shop": {"target": "dev", "outputs": {"dev": {"type": "duckdb"}}}}, f)

ctx = Context(paths=tmp_path)
assert ctx.config.model_defaults.start
assert ctx.config.virtual_environment_mode == VirtualEnvironmentMode.DEV_ONLY