diff --git a/dbt/include/synapse/macros/adapters/show.sql b/dbt/include/synapse/macros/adapters/show.sql index 78b16a0..43984e7 100644 --- a/dbt/include/synapse/macros/adapters/show.sql +++ b/dbt/include/synapse/macros/adapters/show.sql @@ -1,3 +1,14 @@ +{% macro get_show_sql(compiled_code, sql_header, limit) -%} + {%- if sql_header -%} + {{ sql_header }} + {%- endif -%} + {%- if limit is not none -%} + {%- set warn = "--limit is ignored. Synapse doesn't support the implementation" -%} + {{ log(warn, info=True) }} + {%- endif -%} + {{ compiled_code }} + +{% endmacro %} {% macro get_limit_subquery_sql(sql, limit) %} {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }} @@ -5,9 +16,8 @@ {# Synapse doesnt support ANSI LIMIT clause #} {% macro synapse__get_limit_subquery_sql(sql, limit) %} -{%- set warn = "-- limit of " ~ limit ~ " is ignored. Synapse doesn't support the implementation" -%} - -{{ warn }} -{{ sql }} - + select top {{ limit }} * + from ( + {{ sql }} + ) as model_limit_subq {% endmacro %} diff --git a/tests/functional/adapter/test_dbt_show.py b/tests/functional/adapter/test_dbt_show.py index 422286f..6cad141 100644 --- a/tests/functional/adapter/test_dbt_show.py +++ b/tests/functional/adapter/test_dbt_show.py @@ -66,6 +66,5 @@ class TestShowSqlHeaderSynapse(BaseShowSqlHeader): pass -# Disabled because dbt-synapse doesn't support the `--limit` flag -# class TestShowLimitSynapse(BaseShowLimit): -# pass \ No newline at end of file +class TestShowLimitSynapse(BaseShowLimit): + pass