Skip to content

Commit 8eaa319

Browse files
committed
Add engine install command next step
1 parent 8510ad1 commit 8eaa319

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

sqlmesh/cli/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,12 @@ def init(
205205
dlt_path=dlt_path,
206206
)
207207

208+
engine_install_text = ""
209+
if engine_type and engine_type not in ("duckdb", "motherduck", "spark"):
210+
engine_install_text = f'• Run command in CLI to install your SQL engine\'s Python dependencies: pip install "sqlmesh\\[{engine_type.replace("_", "")}]"\n'
211+
# interactive init does not support DLT template
208212
next_step_text = {
209-
ProjectTemplate.DEFAULT: f"• Update your gateway connection settings (e.g., username/password) in the project configuration file:\n {config_path}",
213+
ProjectTemplate.DEFAULT: f"{engine_install_text}• Update your gateway connection settings (e.g., username/password) in the project configuration file:\n {config_path}",
210214
ProjectTemplate.DBT: "",
211215
}
212216
next_step_text[ProjectTemplate.EMPTY] = next_step_text[ProjectTemplate.DEFAULT]

tests/cli/test_cli.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,32 @@ def test_init_interactive_cli_mode_simple(runner: CliRunner, tmp_path: Path):
18821882
assert "no_diff: true" in config_path.read_text()
18831883

18841884

1885+
def test_init_interactive_engine_install_msg(runner: CliRunner, tmp_path: Path):
1886+
# Engine install text should not appear for built-in engines like DuckDB
1887+
# Input: 1 (DEFAULT template), 1 (duckdb engine), 1 (DEFAULT CLI mode)
1888+
result = runner.invoke(
1889+
cli,
1890+
["--paths", str(tmp_path), "init"],
1891+
input="1\n1\n1\n",
1892+
)
1893+
assert result.exit_code == 0
1894+
assert "Run command in CLI to install your SQL engine" not in result.output
1895+
1896+
remove(tmp_path / "config.yaml")
1897+
1898+
# Input: 1 (DEFAULT template), 13 (gcp postgres engine), 1 (DEFAULT CLI mode)
1899+
result = runner.invoke(
1900+
cli,
1901+
["--paths", str(tmp_path), "init"],
1902+
input="1\n13\n1\n",
1903+
)
1904+
assert result.exit_code == 0
1905+
assert (
1906+
'Run command in CLI to install your SQL engine\'s Python dependencies: pip \ninstall "sqlmesh[gcppostgres]"'
1907+
in result.output
1908+
)
1909+
1910+
18851911
# dbt template without dbt_project.yml in directory should error
18861912
def test_init_dbt_template_no_dbt_project(runner: CliRunner, tmp_path: Path):
18871913
# template passed to init

0 commit comments

Comments
 (0)