diff --git a/.changes/unreleased/Fixes-20250207-131424.yaml b/.changes/unreleased/Fixes-20250207-131424.yaml new file mode 100644 index 00000000000..96de873b76e --- /dev/null +++ b/.changes/unreleased/Fixes-20250207-131424.yaml @@ -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 diff --git a/core/dbt/task/show.py b/core/dbt/task/show.py index 8b09a6ee0b1..20b62013bfb 100644 --- a/core/dbt/task/show.py +++ b/core/dbt/task/show.py @@ -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": diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index cd91a2bc3eb..f9751a37936 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -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):