Skip to content

Commit

Permalink
Update ShowTaskDirect to correctly handle --limit -1 (#11284)
Browse files Browse the repository at this point in the history
* Update  to support  properly

* changelog
  • Loading branch information
WilliamDee authored Feb 10, 2025
1 parent 55e0df1 commit 7f32e42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20250207-131424.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Handle `--limit -1` properly in `ShowTaskDirect` so that it propagates None instead of a negative int
time: 2025-02-07T13:14:24.725503-05:00
custom:
Author: WilliamDee
Issue: None
5 changes: 2 additions & 3 deletions core/dbt/task/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ class ShowTaskDirect(ConfiguredTask):
def run(self):
adapter = get_adapter(self.config)
with adapter.connection_named("show", should_release_connection=False):
response, table = adapter.execute(
self.args.inline_direct, fetch=True, limit=self.args.limit
)
limit = None if self.args.limit < 0 else self.args.limit
response, table = adapter.execute(self.args.inline_direct, fetch=True, limit=limit)

output = io.StringIO()
if self.args.output == "json":
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/show/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ def test_inline_direct_pass_quiet(self, project):
# See prior test for explanation of why this is here
run_dbt(["seed"])

def test_inline_direct_pass_no_limit(self, project):
query = f"select * from {project.test_schema}.sample_seed"
(_, log_output) = run_dbt_and_capture(["show", "--inline-direct", query, "--limit", -1])
assert "Previewing inline node" in log_output
assert "sample_num" in log_output
assert "sample_bool" in log_output

# See prior test for explanation of why this is here
run_dbt(["seed"])


class TestShowInlineDirectFail(ShowBase):

Expand Down

0 comments on commit 7f32e42

Please sign in to comment.