diff --git a/.changes/unreleased/Features-20250213-182932.yaml b/.changes/unreleased/Features-20250213-182932.yaml new file mode 100644 index 00000000000..ab18c9c6bf5 --- /dev/null +++ b/.changes/unreleased/Features-20250213-182932.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Enable sample mode for 'build' command +time: 2025-02-13T18:29:32.238857-06:00 +custom: + Author: QMalcolm + Issue: "11298" diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index a324049c90b..bb4b9d64b69 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -179,6 +179,7 @@ def cli(ctx, **kwargs): @p.project_dir @p.resource_type @p.exclude_resource_type +@p.sample @p.select @p.selector @p.show diff --git a/tests/functional/sample_mode/test_sample_mode.py b/tests/functional/sample_mode/test_sample_mode.py index 14df94eb6e8..0935a480718 100644 --- a/tests/functional/sample_mode/test_sample_mode.py +++ b/tests/functional/sample_mode/test_sample_mode.py @@ -122,12 +122,14 @@ def event_catcher(self) -> EventCatcher: return EventCatcher(event_to_catch=JinjaLogInfo) # type: ignore @pytest.mark.parametrize( - "sample_mode_available,run_sample_mode,expected_row_count", + "dbt_command,sample_mode_available,run_sample_mode,expected_row_count", [ - (True, True, 2), - (True, False, 3), - (False, True, 3), - (False, False, 3), + ("run", True, True, 2), + ("run", True, False, 3), + ("run", False, True, 3), + ("run", False, False, 3), + ("build", True, True, 2), + ("build", False, True, 3), ], ) @freezegun.freeze_time("2025-01-03T02:03:0Z") @@ -136,11 +138,12 @@ def test_sample_mode( project, mocker: MockerFixture, event_catcher: EventCatcher, + dbt_command: str, sample_mode_available: bool, run_sample_mode: bool, expected_row_count: int, ): - run_args = ["run"] + run_args = [dbt_command] expected_sample = None if run_sample_mode: run_args.append("--sample=1 day")