From a61d27de6e84f1561bfd196ea5d76fde38c71da5 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Thu, 19 Sep 2024 12:31:28 -0700 Subject: [PATCH 1/2] v1.8.2 changes - Fix https://github.com/oracle/dbt-oracle/issues/136 - Fix https://github.com/oracle/dbt-oracle/issues/153 - Upgrade Python driver to 2.4.1 --- Makefile | 2 +- dbt/adapters/oracle/relation.py | 19 ++++++++++++++++++- dbt/adapters/oracle/sample_profiles.yml | 1 + dbt/include/oracle/macros/relations/drop.sql | 18 +++++++++++++++++- requirements.txt | 2 +- setup.cfg | 4 ++-- setup.py | 4 ++-- 7 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index d36d2ae..d17ecc8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Configuration variables -VERSION=1.8.1 +VERSION=1.8.2 PROJ_DIR?=$(shell pwd) VENV_DIR?=${PROJ_DIR}/.bldenv BUILD_DIR=${PROJ_DIR}/build diff --git a/dbt/adapters/oracle/relation.py b/dbt/adapters/oracle/relation.py index e0a8ec4..c0135ed 100644 --- a/dbt/adapters/oracle/relation.py +++ b/dbt/adapters/oracle/relation.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2022, Oracle and/or its affiliates. +Copyright (c) 2024, Oracle and/or its affiliates. Copyright (c) 2020, Vitor Avancini Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,6 +19,7 @@ from dataclasses import dataclass, field from dbt.adapters.base.relation import BaseRelation +from dbt.adapters.contracts.relation import ComponentName from dbt.adapters.events.logging import AdapterLogger from dbt.adapters.relation_configs import ( RelationConfigBase, @@ -148,3 +149,19 @@ def materialized_view_config_changeset( return config_change_collection return None + + def _is_exactish_match(self, field: ComponentName, value: str) -> bool: + """ + + The only purpose of _is_exactish_match is to detect matches that are + approximate (case-insensitive and quote-stripped) but not exact, + so that dbt can raise an exception saying a too-similar relation + already exists in the cache + + """ + if self.dbt_created and self.quote_policy.get_part(field) is False: + return self.path.get_lowered_part(field) == value.lower() + elif self.quote_policy.get_part(field) is False: + return self.path.get_lowered_part(field) == value.lower() + else: + return self.path.get_part(field) == value diff --git a/dbt/adapters/oracle/sample_profiles.yml b/dbt/adapters/oracle/sample_profiles.yml index acc2465..387cb8a 100644 --- a/dbt/adapters/oracle/sample_profiles.yml +++ b/dbt/adapters/oracle/sample_profiles.yml @@ -7,6 +7,7 @@ default: host: "{{ env_var('DBT_ORACLE_HOST') }}" user: "{{ env_var('DBT_ORACLE_USER') }}" password: "{{ env_var('DBT_ORACLE_PASSWORD') }}" + database: "{{ env_var('DBT_ORACLE_DATABASE') }}" port: 1522 service: "{{ env_var('DBT_ORACLE_SERVICE') }}" schema: "{{ env_var('DBT_ORACLE_SCHEMA') }}" diff --git a/dbt/include/oracle/macros/relations/drop.sql b/dbt/include/oracle/macros/relations/drop.sql index 340bab0..82056ef 100644 --- a/dbt/include/oracle/macros/relations/drop.sql +++ b/dbt/include/oracle/macros/relations/drop.sql @@ -1,3 +1,17 @@ +{# + Copyright (c) 2024, Oracle and/or its affiliates. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- macro oracle__get_drop_sql(relation) -%} DECLARE dne_942 EXCEPTION; @@ -10,8 +24,10 @@ SAVEPOINT start_transaction; {%- if relation.is_materialized_view -%} EXECUTE IMMEDIATE '{{ oracle__drop_materialized_view(relation) }}'; + {%- elif relation.is_table -%} + EXECUTE IMMEDIATE 'DROP table {{ relation }} cascade constraints purge'; {%- else -%} - EXECUTE IMMEDIATE 'DROP {{ relation.type }} {{ relation }} cascade constraint'; + EXECUTE IMMEDIATE 'DROP {{ relation.type }} {{ relation }} cascade constraints'; {%- endif -%} COMMIT; EXCEPTION diff --git a/requirements.txt b/requirements.txt index 9183567..c176417 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ dbt-common>=1.1.0,<2.0 dbt-adapters>=1.2.1,<2.0 dbt-core>=1.8.1,<2.0 -oracledb==2.3.0 +oracledb==2.4.1 diff --git a/setup.cfg b/setup.cfg index c87a843..0da4a20 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dbt-oracle -version = 1.8.1 +version = 1.8.2 description = dbt (data build tool) adapter for Oracle Autonomous Database long_description = file: README.md long_description_content_type = text/markdown @@ -36,7 +36,7 @@ install_requires = dbt-common>=1.1.0,<2.0 dbt-adapters>=1.2.1,<2.0 dbt-core~=1.8,<1.9 - oracledb==2.3.0 + oracledb==2.4.1 test_suite=tests test_requires = dbt-tests-adapter~=1.8,<1.9 diff --git a/setup.py b/setup.py index 31fed00..28efae6 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ "dbt-common>=1.1.0,<2.0", "dbt-adapters>=1.2.1,<2.0", "dbt-core~=1.8,<1.9", - "oracledb==2.3.0" + "oracledb==2.4.1" ] test_requirements = [ @@ -61,7 +61,7 @@ url = 'https://github.com/oracle/dbt-oracle' -VERSION = '1.8.1' +VERSION = '1.8.2' setup( author="Oracle", python_requires='>=3.8', From 679dbdae8fbc697363f8203d5f549ca722baf1d8 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Thu, 19 Sep 2024 13:52:36 -0700 Subject: [PATCH 2/2] Bumped version to 1.8.3 --- Makefile | 2 +- dbt/adapters/oracle/__version__.py | 4 ++-- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d17ecc8..4cd83df 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Configuration variables -VERSION=1.8.2 +VERSION=1.8.3 PROJ_DIR?=$(shell pwd) VENV_DIR?=${PROJ_DIR}/.bldenv BUILD_DIR=${PROJ_DIR}/build diff --git a/dbt/adapters/oracle/__version__.py b/dbt/adapters/oracle/__version__.py index 57528fd..6f8ca09 100644 --- a/dbt/adapters/oracle/__version__.py +++ b/dbt/adapters/oracle/__version__.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2022, Oracle and/or its affiliates. +Copyright (c) 2024, Oracle and/or its affiliates. Copyright (c) 2020, Vitor Avancini Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,4 +14,4 @@ See the License for the specific language governing permissions and limitations under the License. """ -version = "1.8.1" +version = "1.8.3" diff --git a/setup.cfg b/setup.cfg index 0da4a20..422b8cc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dbt-oracle -version = 1.8.2 +version = 1.8.3 description = dbt (data build tool) adapter for Oracle Autonomous Database long_description = file: README.md long_description_content_type = text/markdown diff --git a/setup.py b/setup.py index 28efae6..332cc03 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ url = 'https://github.com/oracle/dbt-oracle' -VERSION = '1.8.2' +VERSION = '1.8.3' setup( author="Oracle", python_requires='>=3.8',