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
3 changes: 2 additions & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ Options:
--no-gaps Ensure that new snapshots have no data gaps
when comparing to existing snapshots for
matching models in the target environment.
--skip-backfill Skip the backfill step.
--skip-backfill, --dry-run Skip the backfill step and only create a
virtual update for the plan.
--forward-only Create a plan for forward-only changes.
--allow-destructive-model TEXT Allow destructive forward-only changes to
models whose names match the expression.
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/notebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ options:
%plan [--start START] [--end END] [--execution-time EXECUTION_TIME]
[--create-from CREATE_FROM] [--skip-tests]
[--restate-model [RESTATE_MODEL ...]] [--no-gaps]
[--skip-backfill] [--forward-only]
[--skip-backfill, --dry-run] [--forward-only]
[--effective-from EFFECTIVE_FROM] [--no-prompts] [--auto-apply]
[--no-auto-categorization] [--include-unmodified]
[--select-model [SELECT_MODEL ...]]
Expand Down Expand Up @@ -127,7 +127,8 @@ options:
--no-gaps, -g Ensure that new snapshots have no data gaps when
comparing to existing snapshots for matching models in
the target environment.
--skip-backfill Skip the backfill step.
--skip-backfill, --dry-run
Skip the backfill step and only create a virtual update for the plan.
--forward-only Create a plan for forward-only changes.
--effective-from EFFECTIVE_FROM
The effective date from which to apply forward-only
Expand Down
3 changes: 2 additions & 1 deletion sqlmesh/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ def diff(ctx: click.Context, environment: t.Optional[str] = None) -> None:
)
@click.option(
"--skip-backfill",
"--dry-run",
is_flag=True,
help="Skip the backfill step.",
help="Skip the backfill step and only create a virtual update for the plan.",
)
@click.option(
"--forward-only",
Expand Down
3 changes: 2 additions & 1 deletion sqlmesh/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ def test(self, context: Context, line: str, test_def_raw: t.Optional[str] = None
)
@argument(
"--skip-backfill",
"--dry-run",
action="store_true",
help="Skip the backfill step.",
help="Skip the backfill step and only create a virtual update for the plan.",
)
@argument(
"--forward-only",
Expand Down
14 changes: 7 additions & 7 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,12 @@ def test_plan_restate_model(runner, tmp_path):
assert_backfill_success(result)


def test_plan_skip_backfill(runner, tmp_path):
@pytest.mark.parametrize("flag", ["--skip-backfill", "--dry-run"])
def test_plan_skip_backfill(runner, tmp_path, flag):
create_example_project(tmp_path)

# plan for `prod` errors if `--skip-backfill` is passed without --no-gaps
result = runner.invoke(
cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--skip-backfill"]
)
result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", flag])
assert result.exit_code == 1
assert (
"Error: When targeting the production environment either the backfill should not be skipped or the lack of data gaps should be enforced (--no-gaps flag)."
Expand All @@ -231,7 +230,7 @@ def test_plan_skip_backfill(runner, tmp_path):
# Input: `y` to perform virtual update
result = runner.invoke(
cli,
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "--skip-backfill", "--no-gaps"],
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", flag, "--no-gaps"],
input="y\n",
)
assert result.exit_code == 0
Expand Down Expand Up @@ -562,15 +561,16 @@ def test_run_no_prod(runner, tmp_path):
assert "Error: Environment 'prod' was not found." in result.output


@pytest.mark.parametrize("flag", ["--skip-backfill", "--dry-run"])
@freeze_time(FREEZE_TIME)
def test_run_dev(runner, tmp_path):
def test_run_dev(runner, tmp_path, flag):
create_example_project(tmp_path)

# Create dev environment but DO NOT backfill
# Input: `y` for virtual update
runner.invoke(
cli,
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "dev", "--skip-backfill"],
["--log-file-dir", tmp_path, "--paths", tmp_path, "plan", "dev", flag],
input="y\n",
)

Expand Down