From 63c650c9ece4ee53caef50f5b41ec063b6bff5b5 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 4 Dec 2023 16:12:29 +0900 Subject: [PATCH 1/7] first pass --- dev-requirements.txt | 6 ++-- .../unit_testing/test_unit_testing_types.py | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tests/functional/adapter/unit_testing/test_unit_testing_types.py diff --git a/dev-requirements.txt b/dev-requirements.txt index 9d68fbed7..3700f3f4d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -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#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git@support-complex-types-unit-testing#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@support-complex-types-unit-testing#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@support-complex-types-unit-testing#egg=dbt-postgres&subdirectory=plugins/postgres # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor diff --git a/tests/functional/adapter/unit_testing/test_unit_testing_types.py b/tests/functional/adapter/unit_testing/test_unit_testing_types.py new file mode 100644 index 000000000..6dd410e8f --- /dev/null +++ b/tests/functional/adapter/unit_testing/test_unit_testing_types.py @@ -0,0 +1,31 @@ +import pytest +from dbt.tests.adapter.unit_testing.test_unit_testing_types import BaseUnitTestingTypes + + +class TestRedshiftUnitTestingTypes(BaseUnitTestingTypes): + @pytest.fixture + def data_types(self): + # sql_value, yaml_value + return [ + ["1", "1"], + ["1.0", "1.0"], + ["'1'", "1"], + ["'1'::numeric", "1"], + ["'string'", "string"], + ["true", "true"], + ["DATE '2020-01-02'", "2020-01-02"], + ["TIMESTAMP '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], + ["TIMESTAMPTZ '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], + ["ARRAY[1,2,3]", """'{1, 2, 3}'"""], + ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""], + ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""], + ["ARRAY['a','b','c']", """'{"a", "b", "c"}'"""], + ["ARRAY[true,true,false]", """'{true, true, false}'"""], + ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""], + ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], + ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], + [ + """'{"bar": "baz", "balance": 7.77, "active": false}'::json""", + """'{"bar": "baz", "balance": 7.77, "active": false}'""", + ], + ] From 89ec16718ed13650801730013ad4cd412c33a0e6 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 5 Feb 2024 18:04:30 -0500 Subject: [PATCH 2/7] fix dbt-common version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4925bb04b..1be3e3ab4 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def _plugin_version() -> str: packages=find_namespace_packages(include=["dbt", "dbt.*"]), include_package_data=True, install_requires=[ - "dbt-common<1.0", + "dbt-common~=0.1.0", "dbt-adapters~=0.1.0a1", f"dbt-postgres~={_plugin_version()}", # dbt-redshift depends deeply on this package. it does not follow SemVer, therefore there have been breaking changes in previous patch releases From 5b3414ea1d17adaf595426e57ab5e2f509c311d3 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 5 Feb 2024 18:11:32 -0500 Subject: [PATCH 3/7] try to fix dbt-postgres version --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 0de6c6ef1..09368e141 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,6 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? +git+https://github.com/dbt-labs/dbt-postgres.git@main git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core git+https://github.com/dbt-labs/dbt-adapters.git@unit-testing-case-insensitive-comparisons git+https://github.com/dbt-labs/dbt-adapters.git@unit-testing-case-insensitive-comparisons#subdirectory=dbt-tests-adapter From 54003c37b48273d0d38eff5ed05007d96721740a Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 5 Feb 2024 19:37:31 -0500 Subject: [PATCH 4/7] fix import --- .../functional/adapter/unit_testing/test_unit_testing_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/adapter/unit_testing/test_unit_testing_types.py b/tests/functional/adapter/unit_testing/test_unit_testing_types.py index 6dd410e8f..33414898c 100644 --- a/tests/functional/adapter/unit_testing/test_unit_testing_types.py +++ b/tests/functional/adapter/unit_testing/test_unit_testing_types.py @@ -1,5 +1,5 @@ import pytest -from dbt.tests.adapter.unit_testing.test_unit_testing_types import BaseUnitTestingTypes +from dbt.tests.adapter.unit_testing.test_unit_testing import BaseUnitTestingTypes class TestRedshiftUnitTestingTypes(BaseUnitTestingTypes): From 92c220dd1234e7f66cbc5f377b969dd2ff35b42a Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 5 Feb 2024 20:49:48 -0500 Subject: [PATCH 5/7] array and json types as TODO --- .../unit_testing/test_unit_testing_types.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/functional/adapter/unit_testing/test_unit_testing_types.py b/tests/functional/adapter/unit_testing/test_unit_testing_types.py index 33414898c..4032f8633 100644 --- a/tests/functional/adapter/unit_testing/test_unit_testing_types.py +++ b/tests/functional/adapter/unit_testing/test_unit_testing_types.py @@ -16,16 +16,17 @@ def data_types(self): ["DATE '2020-01-02'", "2020-01-02"], ["TIMESTAMP '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], ["TIMESTAMPTZ '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], - ["ARRAY[1,2,3]", """'{1, 2, 3}'"""], - ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""], - ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""], - ["ARRAY['a','b','c']", """'{"a", "b", "c"}'"""], - ["ARRAY[true,true,false]", """'{true, true, false}'"""], - ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""], - ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], - ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], - [ - """'{"bar": "baz", "balance": 7.77, "active": false}'::json""", - """'{"bar": "baz", "balance": 7.77, "active": false}'""", - ], + # TOOD: array & json types + # ["ARRAY[1,2,3]", """'{1, 2, 3}'"""], + # ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""], + # ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""], + # ["ARRAY['a','b','c']", """'{"a", "b", "c"}'"""], + # ["ARRAY[true,true,false]", """'{true, true, false}'"""], + # ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""], + # ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], + # ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], + # [ + # """'{"bar": "baz", "balance": 7.77, "active": false}'::json""", + # """'{"bar": "baz", "balance": 7.77, "active": false}'""", + # ], ] From 862677d503d8213651ca349109bed8295d9c2fac Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 6 Feb 2024 18:11:25 -0500 Subject: [PATCH 6/7] add json test, TestRedshiftUnitTestCaseInsensitivity, TestRedshiftUnitTestInvalidInput --- ..._testing_types.py => test_unit_testing.py} | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) rename tests/functional/adapter/unit_testing/{test_unit_testing_types.py => test_unit_testing.py} (64%) diff --git a/tests/functional/adapter/unit_testing/test_unit_testing_types.py b/tests/functional/adapter/unit_testing/test_unit_testing.py similarity index 64% rename from tests/functional/adapter/unit_testing/test_unit_testing_types.py rename to tests/functional/adapter/unit_testing/test_unit_testing.py index 4032f8633..4d89c4b08 100644 --- a/tests/functional/adapter/unit_testing/test_unit_testing_types.py +++ b/tests/functional/adapter/unit_testing/test_unit_testing.py @@ -1,5 +1,7 @@ import pytest -from dbt.tests.adapter.unit_testing.test_unit_testing import BaseUnitTestingTypes +from dbt.tests.adapter.unit_testing.test_types import BaseUnitTestingTypes +from dbt.tests.adapter.unit_testing.test_case_insensitivity import BaseUnitTestCaseInsensivity +from dbt.tests.adapter.unit_testing.test_invalid_input import BaseUnitTestInvalidInput class TestRedshiftUnitTestingTypes(BaseUnitTestingTypes): @@ -16,7 +18,11 @@ def data_types(self): ["DATE '2020-01-02'", "2020-01-02"], ["TIMESTAMP '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], ["TIMESTAMPTZ '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"], - # TOOD: array & json types + [ + """JSON_PARSE('{"bar": "baz", "balance": 7.77, "active": false}')""", + """'{"bar": "baz", "balance": 7.77, "active": false}'""", + ], + # TODO: array types # ["ARRAY[1,2,3]", """'{1, 2, 3}'"""], # ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""], # ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""], @@ -25,8 +31,12 @@ def data_types(self): # ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""], # ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], # ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""], - # [ - # """'{"bar": "baz", "balance": 7.77, "active": false}'::json""", - # """'{"bar": "baz", "balance": 7.77, "active": false}'""", - # ], ] + + +class TestRedshiftUnitTestCaseInsensitivity(BaseUnitTestCaseInsensivity): + pass + + +class TestRedshiftUnitTestInvalidInput(BaseUnitTestInvalidInput): + pass From df685091eeb7c56b1f8708ecb6e8b966db74349c Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 8 Feb 2024 22:29:00 -0500 Subject: [PATCH 7/7] restore requirements --- dev-requirements.txt | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 09368e141..8814be848 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,8 +2,8 @@ # TODO: how to switch from HEAD to x.y.latest branches after minor releases? git+https://github.com/dbt-labs/dbt-postgres.git@main git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-adapters.git@unit-testing-case-insensitive-comparisons -git+https://github.com/dbt-labs/dbt-adapters.git@unit-testing-case-insensitive-comparisons#subdirectory=dbt-tests-adapter +git+https://github.com/dbt-labs/dbt-adapters.git +git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor diff --git a/setup.py b/setup.py index 1be3e3ab4..09b1cea88 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def _plugin_version() -> str: packages=find_namespace_packages(include=["dbt", "dbt.*"]), include_package_data=True, install_requires=[ - "dbt-common~=0.1.0", + "dbt-common>=0.1.0,<0.2.0", "dbt-adapters~=0.1.0a1", f"dbt-postgres~={_plugin_version()}", # dbt-redshift depends deeply on this package. it does not follow SemVer, therefore there have been breaking changes in previous patch releases