Skip to content

Commit

Permalink
Get tests working (Redshift) and correct the limit syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Jun 25, 2024
1 parent d6620e2 commit 8853cd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions dbt-tests-adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from dbt_common.exceptions import DbtRuntimeError
from dbt.tests.adapter.dbt_show import fixtures
from dbt.tests.util import run_dbt

Expand Down Expand Up @@ -48,9 +49,15 @@ def test_sql_header(self, project):


class BaseShowDoesNotHandleDoubleLimit:
"""see issue: https://github.com/dbt-labs/dbt-adapters/issues/207"""

DATABASE_ERROR_MESSAGE = 'syntax error at or near "limit"'

def test_double_limit_throws_syntax_error(self, project):
'''see issue: https://github.com/dbt-labs/dbt-adapters/issues/207'''
run_dbt(["show", "--limit", "1", "--inline", "select 1 limit 1"])
with pytest.raises(DbtRuntimeError) as e:
run_dbt(["show", "--limit", "1", "--inline", "select 1 limit 1"])

assert self.DATABASE_ERROR_MESSAGE in str(e)


class TestPostgresShowSqlHeader(BaseShowSqlHeader):
Expand Down
4 changes: 2 additions & 2 deletions dbt/include/global_project/macros/adapters/show.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
{% endmacro %}

{% macro default__get_show_sql(compiled_code, sql_header, limit) %}
{%- if sql_header -%}
{%- if sql_header is not none -%}
{{ sql_header }}
{%- endif -%}
{{ compiled_code }}
{%- if limit is not none -%}
{%- if limit is not none %}
limit {{ limit }}
{%- endif -%}
{% endmacro %}

0 comments on commit 8853cd3

Please sign in to comment.