From 5b43a16f9c4c79e3ad03d6be07c3682b3a4d41fc Mon Sep 17 00:00:00 2001 From: Pradeep Srikakolapu Date: Sat, 18 May 2024 23:47:15 -0700 Subject: [PATCH 1/4] pinning v1.8.0 dbt adapter and optimizing snapshot issues --- dbt/adapters/fabric/__version__.py | 2 +- .../fabric/macros/materializations/snapshots/snapshot.sql | 5 ++++- setup.py | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dbt/adapters/fabric/__version__.py b/dbt/adapters/fabric/__version__.py index eaf9d19..f2493fc 100644 --- a/dbt/adapters/fabric/__version__.py +++ b/dbt/adapters/fabric/__version__.py @@ -1 +1 @@ -version = "1.8.3" +version = "1.8.4" diff --git a/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql b/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql index 02131f4..83e3f9b 100644 --- a/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql +++ b/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql @@ -54,7 +54,10 @@ | rejectattr('name', 'equalto', 'dbt_unique_key') | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY') | list %} - {% do create_columns(target_relation, missing_columns) %} + {% if missing_columns|length > 0 %} + {{log("Missing columns length is: "~ missing_columns|length)}} + {% do create_columns(target_relation, missing_columns) %} + {% endif %} {% set source_columns = adapter.get_columns_in_relation(staging_table) | rejectattr('name', 'equalto', 'dbt_change_type') | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE') diff --git a/setup.py b/setup.py index e8cc934..3deed70 100644 --- a/setup.py +++ b/setup.py @@ -68,9 +68,9 @@ def run(self): install_requires=[ "pyodbc>=4.0.35,<5.2.0", "azure-identity>=1.12.0", - "dbt-common>=0.1.0a1,<2.0", - "dbt-core>=1.8.0a1", - "dbt-adapters>=0.1.0a1,<2.0", + "dbt-common>=1.0.4,<2.0", + "dbt-core>=1.8.0", + "dbt-adapters>=1.1.1,<2.0", ], cmdclass={ "verify": VerifyVersionCommand, From 17e77c66a20ce94a0e8b15f2e12603694bfb1bb9 Mon Sep 17 00:00:00 2001 From: Pradeep Srikakolapu Date: Sun, 19 May 2024 00:04:54 -0700 Subject: [PATCH 2/4] Pinning to dbt-core v1.8.0 and its requirements --- dev_requirements.txt | 7 ++++--- setup.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index 46d6864..a42c6b9 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,8 +1,9 @@ # 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@fc431010ef0bd11ee6a502fc6c9e5e3e75c5d72d#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-adapters.git@4c289b150853b94beb67921f2a8dd203abe53cbe -git+https://github.com/dbt-labs/dbt-adapters.git@4c289b150853b94beb67921f2a8dd203abe53cbe#subdirectory=dbt-tests-adapter +git+https://github.com/dbt-labs/dbt-core.git@v1.8.0#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-adapters.git +git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter +git+https://github.com/dbt-labs/dbt-common.git pytest==8.0.1 twine==5.0.0 diff --git a/setup.py b/setup.py index 3deed70..b8e33c5 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ def run(self): "pyodbc>=4.0.35,<5.2.0", "azure-identity>=1.12.0", "dbt-common>=1.0.4,<2.0", - "dbt-core>=1.8.0", + "dbt-core==1.8.0", "dbt-adapters>=1.1.1,<2.0", ], cmdclass={ From 186775359b323466e5e35c7ed7ed2d5c5781fbb6 Mon Sep 17 00:00:00 2001 From: Pradeep Srikakolapu Date: Sun, 19 May 2024 00:10:16 -0700 Subject: [PATCH 3/4] Addressing issue #168 --- dbt/include/fabric/macros/materializations/tests/helpers.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/include/fabric/macros/materializations/tests/helpers.sql b/dbt/include/fabric/macros/materializations/tests/helpers.sql index e902553..ad8c4d8 100644 --- a/dbt/include/fabric/macros/materializations/tests/helpers.sql +++ b/dbt/include/fabric/macros/materializations/tests/helpers.sql @@ -2,7 +2,7 @@ {% if main_sql.strip().lower().startswith('with') %} {% set testview %} - {{ generate_schema_name('tests_schema') }}.testview_{{ range(1300, 19000) | random }} + {{ config.get('schema') }}.testview_{{ range(1300, 19000) | random }} {% endset %} {% set sql = main_sql.replace("'", "''")%} From 43a06a955c3cabdc2222f6523c6564fc76926136 Mon Sep 17 00:00:00 2001 From: Pradeep Srikakolapu Date: Sun, 19 May 2024 14:56:03 -0700 Subject: [PATCH 4/4] Updating tests for 1.8.0 version --- tests/functional/adapter/test_constraints.py | 2 -- tests/functional/adapter/test_dbt_clone.py | 3 --- tests/functional/adapter/test_query_comment.py | 7 +++---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/functional/adapter/test_constraints.py b/tests/functional/adapter/test_constraints.py index ed7ed9f..6ff5265 100644 --- a/tests/functional/adapter/test_constraints.py +++ b/tests/functional/adapter/test_constraints.py @@ -44,7 +44,6 @@ description: hello constraints: - type: not_null - - type: primary_key - type: unique - type: check expression: (id > 0) @@ -92,7 +91,6 @@ description: hello constraints: - type: not_null - - type: primary_key - type: check expression: (id > 0) tests: diff --git a/tests/functional/adapter/test_dbt_clone.py b/tests/functional/adapter/test_dbt_clone.py index 29d5009..03108a5 100644 --- a/tests/functional/adapter/test_dbt_clone.py +++ b/tests/functional/adapter/test_dbt_clone.py @@ -84,17 +84,14 @@ def copy_state(self, project_root): def run_and_save_state(self, project_root, with_snapshot=False): results = run_dbt(["seed"]) assert len(results) == 1 - assert not any(r.node.deferred for r in results) results = run_dbt(["run"]) assert len(results) == 2 - assert not any(r.node.deferred for r in results) results = run_dbt(["test"]) assert len(results) == 2 if with_snapshot: results = run_dbt(["snapshot"]) assert len(results) == 1 - assert not any(r.node.deferred for r in results) # copy files self.copy_state(project_root) diff --git a/tests/functional/adapter/test_query_comment.py b/tests/functional/adapter/test_query_comment.py index 1488274..7e4781a 100644 --- a/tests/functional/adapter/test_query_comment.py +++ b/tests/functional/adapter/test_query_comment.py @@ -1,3 +1,5 @@ +import json + from dbt.tests.adapter.query_comment.test_query_comment import ( BaseEmptyQueryComments, BaseMacroArgsQueryComments, @@ -6,8 +8,6 @@ BaseNullQueryComments, BaseQueryComments, ) -from dbt.version import __version__ as dbt_version -import json # Tests # @@ -20,11 +20,10 @@ class TestMacroQueryComments(BaseMacroQueryComments): class TestMacroArgsQueryComments(BaseMacroArgsQueryComments): - def test_matches_comment(self, project) -> bool: + def test_matches_comment(self, project): logs = self.run_get_json() expected_dct = { "app": "dbt++", - "dbt_version": dbt_version, "macro_version": "0.1.0", "message": f"blah: {project.adapter.config.target_name}", }