diff --git a/docs/reference/cli.md b/docs/reference/cli.md index e1957f0eeb..d3d26139d4 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -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. diff --git a/docs/reference/notebook.md b/docs/reference/notebook.md index 5b34da79e9..02be8a84fd 100644 --- a/docs/reference/notebook.md +++ b/docs/reference/notebook.md @@ -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 ...]] @@ -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 diff --git a/sqlmesh/cli/main.py b/sqlmesh/cli/main.py index 411e2a9ea2..dff6f194ea 100644 --- a/sqlmesh/cli/main.py +++ b/sqlmesh/cli/main.py @@ -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", diff --git a/sqlmesh/magics.py b/sqlmesh/magics.py index 51652fc00d..c2fe264f74 100644 --- a/sqlmesh/magics.py +++ b/sqlmesh/magics.py @@ -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", diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 309727c0f7..823b557c4a 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -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)." @@ -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 @@ -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", )