Skip to content

Commit d9acfc4

Browse files
committed
fix: restore type=int on --min-intervals and test_plan_min_intervals deleted by DB2 feature commit
1 parent e971311 commit d9acfc4

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎sqlmesh/cli/main.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def diff(ctx: click.Context, environment: t.Optional[str] = None) -> None:
563563
)
564564
@click.option(
565565
"--min-intervals",
566+
type=int,
566567
default=None,
567568
help="For every model, ensure at least this many intervals are covered by a missing intervals check regardless of the plan start date",
568569
)

‎tests/cli/test_cli.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,44 @@ def test_plan_skip_backfill(runner, tmp_path, flag):
387387
assert "Model batches executed" not in result.output
388388

389389

390+
def test_plan_min_intervals(runner, tmp_path):
391+
create_example_project(tmp_path)
392+
393+
# build prod so the dev plan below has a baseline to diff against
394+
runner.invoke(
395+
cli,
396+
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--no-prompts", "--auto-apply"],
397+
)
398+
update_incremental_model(tmp_path)
399+
400+
# --min-intervals must be coerced to int; otherwise the string reaches
401+
# range() in _calculate_start_override_per_model and raises TypeError
402+
result = runner.invoke(
403+
cli,
404+
[
405+
"--log-file-dir",
406+
tmp_path,
407+
"--paths",
408+
tmp_path,
409+
"plan",
410+
"dev",
411+
"--no-prompts",
412+
"--auto-apply",
413+
"--min-intervals",
414+
"1",
415+
],
416+
)
417+
assert result.exit_code == 0, result.output
418+
419+
# a non-integer value is rejected by click, not surfaced as a traceback
420+
result = runner.invoke(
421+
cli,
422+
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "dev", "--min-intervals", "abc"],
423+
)
424+
assert result.exit_code == 2
425+
assert "is not a valid integer" in result.output
426+
427+
390428
def test_plan_auto_apply(runner, tmp_path):
391429
create_example_project(tmp_path)
392430

0 commit comments

Comments
 (0)