Skip to content

Commit

Permalink
Allow for running sample mode with build command (#11307)
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm authored Feb 14, 2025
1 parent 7041e58 commit aa30669
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20250213-182932.yaml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions tests/functional/sample_mode/test_sample_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit aa30669

Please sign in to comment.