From 21e656dc89759f05b0ac757638a9a9a8375efdd1 Mon Sep 17 00:00:00 2001 From: Varun Sharma Date: Tue, 27 Aug 2024 17:28:35 +0530 Subject: [PATCH] fixed the dbt show command (#187) --- dbt/include/teradata/macros/show.sql | 12 ++++++------ tests/functional/adapter/test_dbt_show.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dbt/include/teradata/macros/show.sql b/dbt/include/teradata/macros/show.sql index 9beaa1df..e36a1e2a 100644 --- a/dbt/include/teradata/macros/show.sql +++ b/dbt/include/teradata/macros/show.sql @@ -1,7 +1,7 @@ --- This macro is overriden because limit keyword doesnot work in teradata database and has been replaced with top keyword -{% macro teradata__get_limit_subquery_sql(sql, limit) %} - select top {{ limit }} * - from ( - {{ sql }} - ) as model_limit_subq +-- This macro is overriden because limit keyword doesnot work in teradata database and has been replaced with sample keyword +{% macro teradata__get_limit_sql(sql, limit) %} + {{ compiled_code }} + {% if limit is not none %} + sample {{ limit }} + {%- endif -%} {% endmacro %} \ No newline at end of file diff --git a/tests/functional/adapter/test_dbt_show.py b/tests/functional/adapter/test_dbt_show.py index afca6226..dab2881e 100644 --- a/tests/functional/adapter/test_dbt_show.py +++ b/tests/functional/adapter/test_dbt_show.py @@ -38,7 +38,7 @@ def test_limit(self, project, args, expected): # ensure limit was injected in compiled_code when limit specified in command args limit = results.args.get("limit") if limit > 0: - assert f"top {limit}" in results.results[0].node.compiled_code #used top keyword in place of limit keyword + assert f"sample {limit}" in results.results[0].node.compiled_code #used sample keyword in place of limit keyword class BaseShowSqlHeader: