From 8577fa59775f24cb18d1cbc5739dc236b91c00d6 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 18 Sep 2023 21:17:14 +0100 Subject: [PATCH 1/9] add dbt show tests --- dev-requirements.txt | 4 +-- .../adapter/dbt_show/test_dbt_show.py | 29 +++++++++++++++++++ 2 files changed, 31 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 54ca40f26..cfe0df2cc 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..6a522b06b --- /dev/null +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -0,0 +1,29 @@ +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) %} +DECLARE DEMO STRING DEFAULT 'hello world'; +{% endcall %} + +SELECT DEMO 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 7bfe1f221300d6241ab45bf8add2e1569b02b1cd Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 25 Sep 2023 14:36:43 +0100 Subject: [PATCH 2/9] changelog entry --- .changes/unreleased/Under the Hood-20230925-143628.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20230925-143628.yaml diff --git a/.changes/unreleased/Under the Hood-20230925-143628.yaml b/.changes/unreleased/Under the Hood-20230925-143628.yaml new file mode 100644 index 000000000..fb925ae40 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230925-143628.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:36:28.335466+01:00 +custom: + Author: michelleark + Issue: "940" From 6b180bf80e6f3c7572925839cbba02bf6aaac3fc Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 28 Sep 2023 10:46:43 -0500 Subject: [PATCH 3/9] 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 cfe0df2cc..54ca40f26 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 e27c4e13cbc9e39ff4438ceaed9817426aaf5460 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 28 Sep 2023 19:01:48 +0100 Subject: [PATCH 4/9] reuse core fixture for dbt show sql header test --- dev-requirements.txt | 4 ++-- .../adapter/dbt_show/test_dbt_show.py | 22 +------------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 54ca40f26..fa5c37b49 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 diff --git a/tests/functional/adapter/dbt_show/test_dbt_show.py b/tests/functional/adapter/dbt_show/test_dbt_show.py index 6a522b06b..c60a26aec 100644 --- a/tests/functional/adapter/dbt_show/test_dbt_show.py +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -1,29 +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) %} -DECLARE DEMO STRING DEFAULT 'hello world'; -{% endcall %} - -SELECT DEMO 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 3268ec6f247d760271585acfc52a14b8ca91ae89 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 28 Sep 2023 11:34:58 -0700 Subject: [PATCH 5/9] fix dev-requirements.txt --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index fa5c37b49..54ca40f26 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 From 4cfb4643a3381286a918e59377f565048cc35c5d Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 21 Jul 2023 15:58:31 -0700 Subject: [PATCH 6/9] use dynamic schema in test_grant_access_to.py --- tests/functional/adapter/test_grant_access_to.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/functional/adapter/test_grant_access_to.py b/tests/functional/adapter/test_grant_access_to.py index 633cebe92..3ee7047d3 100644 --- a/tests/functional/adapter/test_grant_access_to.py +++ b/tests/functional/adapter/test_grant_access_to.py @@ -87,6 +87,14 @@ def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant class TestAccessGrantFails: + @pytest.fixture(scope="class", autouse=True) + def setup(self, project): + with project.adapter.connection_named("__test_grants"): + relation = project.adapter.Relation.create( + database=project.database, schema=f"{project.test_schema}_seeds" + ) + yield relation + project.adapter.drop_relation(relation) @pytest.fixture(scope="class") def models(self): return { From 86fecdd1107cb9b2497a2ce4d7938f74e0c8bf9b Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 21 Jul 2023 15:58:51 -0700 Subject: [PATCH 7/9] use dynamic schema in test_grant_access_to.py --- tests/functional/adapter/test_grant_access_to.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/adapter/test_grant_access_to.py b/tests/functional/adapter/test_grant_access_to.py index 3ee7047d3..77213bf26 100644 --- a/tests/functional/adapter/test_grant_access_to.py +++ b/tests/functional/adapter/test_grant_access_to.py @@ -95,6 +95,7 @@ def setup(self, project): ) yield relation project.adapter.drop_relation(relation) + @pytest.fixture(scope="class") def models(self): return { From 21573ef63ff14c1679f4db6b416367cd1e65ae94 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 22 Sep 2023 11:45:24 -0700 Subject: [PATCH 8/9] revert setup --- tests/functional/adapter/test_grant_access_to.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/functional/adapter/test_grant_access_to.py b/tests/functional/adapter/test_grant_access_to.py index 77213bf26..633cebe92 100644 --- a/tests/functional/adapter/test_grant_access_to.py +++ b/tests/functional/adapter/test_grant_access_to.py @@ -87,15 +87,6 @@ def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant class TestAccessGrantFails: - @pytest.fixture(scope="class", autouse=True) - def setup(self, project): - with project.adapter.connection_named("__test_grants"): - relation = project.adapter.Relation.create( - database=project.database, schema=f"{project.test_schema}_seeds" - ) - yield relation - project.adapter.drop_relation(relation) - @pytest.fixture(scope="class") def models(self): return { From f80be086e72a3c1a8719017177a0240484863047 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 28 Sep 2023 11:37:21 -0700 Subject: [PATCH 9/9] fix dev-requirements.txt --- dev-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index fa5c37b49..54ca40f26 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