Skip to content

Commit 84b8fdc

Browse files
committed
Add engine install command next step
1 parent 1f4f5b6 commit 84b8fdc

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
@@ -204,8 +204,12 @@ def init(
204204
dlt_path=dlt_path,
205205
)
206206

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