diff --git a/.github/workflows/oracle-xe-adapter-tests.yml b/.github/workflows/oracle-xe-adapter-tests.yml index a23627a..95e36bf 100644 --- a/.github/workflows/oracle-xe-adapter-tests.yml +++ b/.github/workflows/oracle-xe-adapter-tests.yml @@ -48,7 +48,7 @@ jobs: - name: Install dbt-oracle with core dependencies run: | python -m pip install --upgrade pip - pip install pytest dbt-tests-adapter~=1.6 + pip install pytest 'dbt-tests-adapter~=1.6,<1.7' pip install -r requirements.txt pip install -e . diff --git a/Makefile b/Makefile index 618e97f..ef21c32 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Configuration variables -VERSION=1.6.0 +VERSION=1.6.1 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 88ddfba..ed4e772 100644 --- a/dbt/adapters/oracle/__version__.py +++ b/dbt/adapters/oracle/__version__.py @@ -14,4 +14,4 @@ See the License for the specific language governing permissions and limitations under the License. """ -version = "1.6.0" +version = "1.6.7" diff --git a/dbt/adapters/oracle/connections.py b/dbt/adapters/oracle/connections.py index 194bf8a..72abca0 100644 --- a/dbt/adapters/oracle/connections.py +++ b/dbt/adapters/oracle/connections.py @@ -17,9 +17,11 @@ from typing import List, Optional, Tuple, Any, Dict, Union from contextlib import contextmanager from dataclasses import dataclass, field +import json import enum import time import uuid +import platform import dbt.exceptions from dbt.adapters.base import Credentials @@ -112,6 +114,9 @@ class OracleAdapterCredentials(Credentials): # Base URL for ADB-S OML REST API oml_cloud_service_url: Optional[str] = None + # session info is stored in v$session for each dbt run + session_info: Optional[Dict[str, str]] = field(default_factory=dict) + _ALIASES = { 'dbname': 'database', @@ -136,7 +141,8 @@ def _connection_keys(self) -> Tuple[str]: 'service', 'connection_string', 'shardingkey', 'supershardingkey', 'cclass', 'purity', 'retry_count', - 'retry_delay', 'oml_cloud_service_url' + 'retry_delay', 'oml_cloud_service_url', + 'session_info' ) @classmethod @@ -174,6 +180,19 @@ def get_dsn(self) -> str: class OracleAdapterConnectionManager(SQLConnectionManager): TYPE = 'oracle' + @staticmethod + def get_session_info(credentials): + default_action = "DBT RUN" + default_client_identifier = f'dbt-oracle-client-{uuid.uuid4()}' + default_client_info = "_".join([platform.node(), platform.machine()]) + default_module = f'dbt-{dbt_version}' + return { + "action": credentials.session_info.get("action", default_action), + "client_identifier": credentials.session_info.get("client_identifier", default_client_identifier), + "clientinfo": credentials.session_info.get("client_info", default_client_info), + "module": credentials.session_info.get("module", default_module) + } + @classmethod def open(cls, connection): if connection.state == 'open': @@ -219,8 +238,14 @@ def open(cls, connection): try: handle = oracledb.connect(**conn_config) # client_identifier and module are saved in corresponding columns in v$session - handle.module = f'dbt-{dbt_version}' - handle.client_identifier = f'dbt-oracle-client-{uuid.uuid4()}' + session_info = cls.get_session_info(credentials=credentials) + logger.info(f"Session info :{json.dumps(session_info)}") + for k, v in session_info.items(): + try: + setattr(handle, k, v) + except AttributeError: + logger.warning(f"Python driver does not support setting {k}") + connection.handle = handle connection.state = 'open' except oracledb.DatabaseError as e: diff --git a/dbt_adbs_test_project/profiles.yml b/dbt_adbs_test_project/profiles.yml index b211f52..eb2c4f2 100644 --- a/dbt_adbs_test_project/profiles.yml +++ b/dbt_adbs_test_project/profiles.yml @@ -12,6 +12,11 @@ dbt_test: #database: "{{ env_var('DBT_ORACLE_DATABASE') }}" schema: "{{ env_var('DBT_ORACLE_SCHEMA') }}" oml_cloud_service_url: "{{ env_var('DBT_ORACLE_OML_CLOUD_SERVICE_URL')}}" + session_info: + action: "dbt run" + client_identifier: "dbt-mac-abhisoms" + client_info: "dbt Python3.9 thin driver" + module: "dbt-module-1.5.2" retry_count: 1 retry_delay: 5 shardingkey: @@ -42,6 +47,11 @@ dbt_test: database: "{{ env_var('DBT_ORACLE_DATABASE') }}" tns_name: "{{ env_var('DBT_ORACLE_TNS_NAME') }}" schema: "{{ env_var('DBT_ORACLE_SCHEMA') }}" + session_info: + action: "dbt run" + client_identifier: "dbt-mac-abhisoms" + client_info: "dbt Python3.9 thin driver" + module: "dbt-module-1.5.2" shardingkey: - skey supershardingkey: diff --git a/requirements.txt b/requirements.txt index a74d134..c40f33b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -dbt-core~=1.6 +dbt-core~=1.6,<1.7 cx_Oracle==8.3.0 -oracledb==1.4.1 +oracledb==1.4.2 diff --git a/requirements_dev.txt b/requirements_dev.txt index 2f36520..f510d3c 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,4 +6,4 @@ tox coverage twine pytest -dbt-tests-adapter~=1.6 +dbt-tests-adapter~=1.6,<1.7 diff --git a/setup.cfg b/setup.cfg index 5e262fb..01ecd2a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dbt-oracle -version = 1.6.0 +version = 1.6.1 description = dbt (data build tool) adapter for the Oracle database long_description = file: README.md long_description_content_type = text/markdown @@ -32,9 +32,9 @@ zip_safe = False packages = find_namespace: include_package_data = True install_requires = - dbt-core~=1.6 + dbt-core~=1.6,<1.7 cx_Oracle==8.3.0 - oracledb==1.4.1 + oracledb==1.4.2 test_suite=tests test_requires = dbt-tests-adapter~=1.6 diff --git a/setup.py b/setup.py index 4e54706..662e363 100644 --- a/setup.py +++ b/setup.py @@ -40,13 +40,13 @@ requirements = [ - "dbt-core~=1.6", + "dbt-core~=1.6,<1.7", "cx_Oracle==8.3.0", - "oracledb==1.4.1" + "oracledb==1.4.2" ] test_requirements = [ - "dbt-tests-adapter~=1.6", + "dbt-tests-adapter~=1.6,<1.7", "pytest" ] @@ -60,7 +60,7 @@ url = 'https://github.com/oracle/dbt-oracle' -VERSION = '1.6.0' +VERSION = '1.6.1' setup( author="Oracle", python_requires='>=3.8', diff --git a/tox.ini b/tox.ini index c144234..6473a51 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ passenv = deps = -rrequirements.txt - dbt-tests-adapter~=1.6 + dbt-tests-adapter~=1.6,<1.7 pytest commands = pytest