diff --git a/.changes/unreleased/Features-20240424-180639.yaml b/.changes/unreleased/Features-20240424-180639.yaml new file mode 100644 index 00000000000..dbb4fb9b2ac --- /dev/null +++ b/.changes/unreleased/Features-20240424-180639.yaml @@ -0,0 +1,6 @@ +kind: Features +body: add --empty flag to dbt build command +time: 2024-04-24T18:06:39.438457-04:00 +custom: + Author: michelleark + Issue: "10026" diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 07a9de861a7..35a01700acd 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -170,6 +170,7 @@ def cli(ctx, **kwargs): @cli.command("build") @click.pass_context @global_flags +@p.empty @p.exclude @p.export_saved_queries @p.full_refresh diff --git a/tests/functional/adapter/empty/__init__.py b/tests/functional/adapter/empty/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/functional/adapter/empty/test_empty.py b/tests/functional/test_empty.py similarity index 80% rename from tests/functional/adapter/empty/test_empty.py rename to tests/functional/test_empty.py index a014a640c1f..8e6e834427f 100644 --- a/tests/functional/adapter/empty/test_empty.py +++ b/tests/functional/test_empty.py @@ -37,7 +37,7 @@ """ -class BaseTestEmpty: +class TestEmptyFlag: @pytest.fixture(scope="class") def seeds(self): return { @@ -70,6 +70,13 @@ def test_run_with_empty(self, project): run_dbt(["run", "--empty"]) self.assert_row_count(project, "model", 0) + # build without empty - 3 expected rows in output - 1 from each input + run_dbt(["build"]) + self.assert_row_count(project, "model", 3) + + # build with empty - 0 expected rows in output + run_dbt(["build", "--empty"]) + self.assert_row_count(project, "model", 0) -class TestEmpty(BaseTestEmpty): - pass + # ensure dbt compile supports --empty flag + run_dbt(["compile", "--empty"])