From 3fcbca15d2a2c6c46d5415ff6a2562f62e81b389 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Thu, 22 Feb 2024 15:17:42 -0500 Subject: [PATCH] Rename flag + refactor per #9629 --- core/dbt/cli/main.py | 3 ++- core/dbt/cli/params.py | 11 ++++++++++- core/dbt/task/build.py | 5 +---- .../saved_queries/test_saved_query_build.py | 7 ++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 924f0e397bb..fee719e168c 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -187,8 +187,9 @@ def cli(ctx, **kwargs): @click.pass_context @global_flags @p.exclude +@p.export_saved_queries @p.full_refresh -@p.include_saved_query +@p.deprecated_include_saved_query @p.profile @p.profiles_dir @p.project_dir diff --git a/core/dbt/cli/params.py b/core/dbt/cli/params.py index 3e03376f890..96ab6e63728 100644 --- a/core/dbt/cli/params.py +++ b/core/dbt/cli/params.py @@ -105,6 +105,14 @@ help="Specify the nodes to exclude.", ) +export_saved_queries = click.option( + "--export-saved-queries/--no-export-saved-queries", + envvar="DBT_EXPORT_SAVED_QUERIES", + help="Export saved queries within the 'build' command, otherwise no-op", + is_flag=True, + hidden=True, +) + fail_fast = click.option( "--fail-fast/--no-fail-fast", "-x/ ", @@ -406,7 +414,8 @@ default=(), ) -include_saved_query = click.option( +# Renamed to --export-saved-queries +deprecated_include_saved_query = click.option( "--include-saved-query/--no-include-saved-query", envvar="DBT_INCLUDE_SAVED_QUERY", help="Include saved queries in the list of resources to be selected for build command", diff --git a/core/dbt/task/build.py b/core/dbt/task/build.py index d2a0f668302..7c11839942a 100644 --- a/core/dbt/task/build.py +++ b/core/dbt/task/build.py @@ -70,6 +70,7 @@ class BuildTask(RunTask): NodeType.Seed: seed_runner, NodeType.Test: test_runner, NodeType.Unit: test_runner, + NodeType.SavedQuery: SavedQueryRunner, } ALL_RESOURCE_VALUES = frozenset({x for x in RUNNER_MAP.keys()}) @@ -79,10 +80,6 @@ def __init__(self, args, config, manifest) -> None: self.model_to_unit_test_map: Dict[str, List] = {} def resource_types(self, no_unit_tests=False): - if self.args.include_saved_query: - self.RUNNER_MAP[NodeType.SavedQuery] = SavedQueryRunner - self.ALL_RESOURCE_VALUES = self.ALL_RESOURCE_VALUES.union({NodeType.SavedQuery}) - if not self.args.resource_types: resource_types = list(self.ALL_RESOURCE_VALUES) else: diff --git a/tests/functional/saved_queries/test_saved_query_build.py b/tests/functional/saved_queries/test_saved_query_build.py index ffe37761521..2760c5cab55 100644 --- a/tests/functional/saved_queries/test_saved_query_build.py +++ b/tests/functional/saved_queries/test_saved_query_build.py @@ -28,11 +28,8 @@ def packages(self): version: 1.1.1 """ - def test_semantic_model_parsing(self, project): + def test_build_saved_queries(self, project): run_dbt(["deps"]) result = run_dbt(["build"]) - assert len(result.results) == 2 - assert "test_saved_query" not in [r.node.name for r in result.results] - result = run_dbt(["build", "--include-saved-query"]) assert len(result.results) == 3 - assert "test_saved_query" in [r.node.name for r in result.results] + assert "NO-OP" in [r.node.status for r in result.results]