diff --git a/core/dbt/task/show.py b/core/dbt/task/show.py index eb52a392757..94677bd85db 100644 --- a/core/dbt/task/show.py +++ b/core/dbt/task/show.py @@ -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( 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) end_time = time.time() diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index 1dc59c27cb9..7a0c4a3f99a 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -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):