Skip to content

Commit

Permalink
test limit included in show sql
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Sep 13, 2023
1 parent d77bfe2 commit 0cafc07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/dbt/task/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def execute(self, compiled_node, manifest):
limit = None if self.config.args.limit < 0 else self.config.args.limit

model_context = generate_runtime_model_context(compiled_node, self.config, manifest)
show_limit_sql = self.adapter.execute_macro(
compiled_node.compiled_code = self.adapter.execute_macro(

Check warning on line 28 in core/dbt/task/show.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/show.py#L27-L28

Added lines #L27 - L28 were not covered by tests
macro_name="show",
manifest=manifest,
context_override=model_context,
kwargs={"limit": limit},
)
adapter_response, execute_result = self.adapter.execute(show_limit_sql, fetch=True)
adapter_response, execute_result = self.adapter.execute(compiled_node.compiled_code, fetch=True)

Check warning on line 34 in core/dbt/task/show.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/show.py#L34

Added line #L34 was not covered by tests

end_time = time.time()

Expand Down
3 changes: 3 additions & 0 deletions tests/functional/show/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ def test_limit(self, project, args, expected):
dbt_args = ["show", "--inline", models__second_ephemeral_model, *args]
results = run_dbt(dbt_args)
assert len(results.results[0].agate_table) == expected
# ensure limit was injected in compiled_code when limit specified in command args
if results.args.get('limit') > 0:
assert 'limit' in results.results[0].node.compiled_code


class TestShowSeed(ShowBase):
Expand Down

0 comments on commit 0cafc07

Please sign in to comment.