Skip to content

Commit

Permalink
Rename flag + refactor per #9629
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Feb 22, 2024
1 parent d3de294 commit 3fcbca1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/ ",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions core/dbt/task/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()})

Expand All @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions tests/functional/saved_queries/test_saved_query_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit 3fcbca1

Please sign in to comment.