Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ShowTaskDirect to correctly handle --limit -1 #11284

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/show.py#L131-L132

Added lines #L131 - L132 were not covered by tests

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