From 2adac334b80a2554a4fb90fb465b9109cd9b9c93 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 18 Sep 2023 22:18:55 +0100 Subject: [PATCH 1/6] add dbt show tests --- dev-requirements.txt | 4 +-- .../adapter/dbt_show/test_dbt_show.py | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/functional/adapter/dbt_show/test_dbt_show.py diff --git a/dev-requirements.txt b/dev-requirements.txt index c696a773c..381748568 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@8496/limit-in-show-query#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@8496/limit-in-show-query#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor diff --git a/tests/functional/adapter/dbt_show/test_dbt_show.py b/tests/functional/adapter/dbt_show/test_dbt_show.py new file mode 100644 index 000000000..9168ecb50 --- /dev/null +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -0,0 +1,27 @@ +import pytest +from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowSqlHeader, BaseShowLimit + + +my_model_sql_header_sql = """ +{{ + config( + materialized = "table" + ) +}} +{% call set_sql_header(config) %} +SET MY_VARIABLE='test'; +{% endcall %} +SELECT $MY_VARIABLE as column_name +""" + + +class TestBigQueryShowLimit(BaseShowLimit): + pass + + +class TestBigQueryShowSqlHeader(BaseShowSqlHeader): + @pytest.fixture(scope="class") + def models(self): + return { + "sql_header.sql": my_model_sql_header_sql, + } From 7b8dbc26a78a1b8b2e308fc7a7396a820cdfff77 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 25 Sep 2023 14:48:27 +0100 Subject: [PATCH 2/6] changelog entry --- .changes/unreleased/Under the Hood-20230925-144814.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20230925-144814.yaml diff --git a/.changes/unreleased/Under the Hood-20230925-144814.yaml b/.changes/unreleased/Under the Hood-20230925-144814.yaml new file mode 100644 index 000000000..df7e17255 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230925-144814.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Add tests for inlined limit + sql_header in dbt show query +time: 2023-09-25T14:48:14.663178+01:00 +custom: + Author: michelleark + Issue: "786" From c61c052247f5264afe6d6311ca414a0a6fbe60ba Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 28 Sep 2023 10:45:23 -0500 Subject: [PATCH 3/6] repoint to core main --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 381748568..c696a773c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git@8496/limit-in-show-query#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@8496/limit-in-show-query#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor From 669e6dfdfb5f6cb7d358f7feb6bf5f57c97841da Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 28 Sep 2023 19:10:26 +0100 Subject: [PATCH 4/6] reuse core fixture for dbt show sql header test --- .../adapter/dbt_show/test_dbt_show.py | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/tests/functional/adapter/dbt_show/test_dbt_show.py b/tests/functional/adapter/dbt_show/test_dbt_show.py index 9168ecb50..c60a26aec 100644 --- a/tests/functional/adapter/dbt_show/test_dbt_show.py +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -1,27 +1,9 @@ -import pytest from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowSqlHeader, BaseShowLimit -my_model_sql_header_sql = """ -{{ - config( - materialized = "table" - ) -}} -{% call set_sql_header(config) %} -SET MY_VARIABLE='test'; -{% endcall %} -SELECT $MY_VARIABLE as column_name -""" - - class TestBigQueryShowLimit(BaseShowLimit): pass class TestBigQueryShowSqlHeader(BaseShowSqlHeader): - @pytest.fixture(scope="class") - def models(self): - return { - "sql_header.sql": my_model_sql_header_sql, - } + pass From 958804f406cf76307558ba4958659d5f21741511 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 28 Sep 2023 19:11:16 +0100 Subject: [PATCH 5/6] point to @improve-show-fixture dbt-core branch --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index c696a773c..29adf869e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@improve-show-fixture#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@improve-show-fixture#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor From 71704411897280b962176105dcaadce7abea08df Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 28 Sep 2023 19:43:36 +0100 Subject: [PATCH 6/6] undo dev-requirements changes --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 29adf869e..c696a773c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git@improve-show-fixture#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@improve-show-fixture#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor