Skip to content
Open
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
1 change: 1 addition & 0 deletions sqlmesh/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ def diff(ctx: click.Context, environment: t.Optional[str] = None) -> None:
)
@click.option(
"--min-intervals",
type=int,
default=None,
help="For every model, ensure at least this many intervals are covered by a missing intervals check regardless of the plan start date",
)
Expand Down
38 changes: 38 additions & 0 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,44 @@ def test_plan_skip_backfill(runner, tmp_path, flag):
assert "Model batches executed" not in result.output


def test_plan_min_intervals(runner, tmp_path):
create_example_project(tmp_path)

# build prod so the dev plan below has a baseline to diff against
runner.invoke(
cli,
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--no-prompts", "--auto-apply"],
)
update_incremental_model(tmp_path)

# --min-intervals must be coerced to int; otherwise the string reaches
# range() in _calculate_start_override_per_model and raises TypeError
result = runner.invoke(
cli,
[
"--log-file-dir",
tmp_path,
"--paths",
tmp_path,
"plan",
"dev",
"--no-prompts",
"--auto-apply",
"--min-intervals",
"1",
],
)
assert result.exit_code == 0, result.output

# a non-integer value is rejected by click, not surfaced as a traceback
result = runner.invoke(
cli,
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "dev", "--min-intervals", "abc"],
)
assert result.exit_code == 2
assert "is not a valid integer" in result.output


def test_plan_auto_apply(runner, tmp_path):
create_example_project(tmp_path)

Expand Down