Skip to content

Commit 1393b91

Browse files
committed
Merge branch 'main' of github.com:oracle/dbt-oracle into bug_179
Addign fix for bug_179
2 parents 84f021d + 456ceb9 commit 1393b91

29 files changed

+439
-149
lines changed

.github/scripts/create_new_user.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -Exeuo pipefail
55
# Parameters
66
DB_USER="${1}"
77
DB_PASSWORD="${2}"
8-
TARGET_PDB="${3:-XEPDB1}"
8+
TARGET_PDB="${3:-FREEPDB1}"
99

1010
# Prepare container switch statement to create user in PDB.
1111
ALTER_SESSION_CMD="ALTER SESSION SET CONTAINER=${TARGET_PDB};"
@@ -21,7 +21,7 @@ sqlplus -s / as sysdba << EOF
2121
-- Exit on any errors
2222
WHENEVER SQLERROR EXIT SQL.SQLCODE
2323
${ALTER_SESSION_CMD}
24-
CREATE USER ${DB_USER} IDENTIFIED BY "${DB_PASSWORD}" QUOTA UNLIMITED ON USERS;
25-
GRANT ALL PRIVILEGES TO ${DB_USER};
24+
CREATE USER ${DB_USER} IDENTIFIED BY "${DB_PASSWORD}" QUOTA UNLIMITED ON SYSTEM;
25+
GRANT DB_DEVELOPER_ROLE TO ${DB_USER};
2626
exit;
2727
EOF
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
sudo apt-get update
2-
sudo apt-get install wget libaio1
2+
sudo apt-get install wget libaio1t64
33
sudo mkdir -p /opt/oracle
4-
wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basiclite-linux.x64-21.6.0.0.0dbru.zip -P /tmp
5-
sudo unzip /tmp/instantclient-basiclite-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle
6-
export PATH="$PATH:/opt/oracle/instantclient_21_6"
7-
export LD_LIBRARY_PATH="/opt/oracle/instantclient_21_6:$LD_LIBRARY_PATH"
4+
wget https://download.oracle.com/otn_software/linux/instantclient/2370000/instantclient-basiclite-linux.x64-23.7.0.25.01.zip -P /tmp
5+
sudo unzip /tmp/instantclient-basiclite-linux.x64-23.7.0.25.01.zip -d /opt/oracle
6+
export PATH="$PATH:/opt/oracle/instantclient_23_7"
7+
export LD_LIBRARY_PATH="/opt/oracle/instantclient_23_7:$LD_LIBRARY_PATH"
8+
sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1
89
sudo mkdir -p /opt/tns_admin
910
echo "DISABLE_OOB=ON" >> /opt/tns_admin/sqlnet.ora
1011

.github/workflows/oracle-xe-adapter-tests.yml renamed to .github/workflows/dbt-oracle-adapter-tests.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ name: dbt-tests-adapter
22
on: push
33

44
jobs:
5-
oracle_xe_21_3:
5+
dbt_oracle_adapter_tests:
66
runs-on: ${{ matrix.os }}
77
strategy:
88
fail-fast: true
99
matrix:
1010
os: [ ubuntu-latest ]
11-
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12']
11+
python-version: ['3.9', '3.10', '3.11', '3.12']
1212

1313
services:
14-
oracle_db_xe:
15-
image: container-registry.oracle.com/database/express:21.3.0-xe
14+
oracle_db:
15+
image: container-registry.oracle.com/database/free:latest-lite
1616
env:
1717
ORACLE_PWD: ${{ secrets.DBT_ORACLE_PASSWORD }}
18-
options: --name oracle_db_xe
18+
options: --name oracle_db
1919
ports:
2020
- 1521:1521
2121

@@ -36,19 +36,19 @@ jobs:
3636
- name: Copy Create User script
3737
run: |
3838
chmod +x ${{ github.workspace }}/.github/scripts/create_new_user.sh
39-
docker cp ${{ github.workspace }}/.github/scripts/create_new_user.sh oracle_db_xe:/home/oracle/create_new_user.sh
39+
docker cp ${{ github.workspace }}/.github/scripts/create_new_user.sh oracle_db:/home/oracle/create_new_user.sh
4040
4141
- name: Create dbt test users
4242
run: |
43-
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test ${{ secrets.DBT_ORACLE_PASSWORD }}
44-
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_1 ${{ secrets.DBT_ORACLE_PASSWORD }}
45-
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_2 ${{ secrets.DBT_ORACLE_PASSWORD }}
46-
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_3 ${{ secrets.DBT_ORACLE_PASSWORD }}
43+
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test ${{ secrets.DBT_ORACLE_PASSWORD }}
44+
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_1 ${{ secrets.DBT_ORACLE_PASSWORD }}
45+
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_2 ${{ secrets.DBT_ORACLE_PASSWORD }}
46+
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_3 ${{ secrets.DBT_ORACLE_PASSWORD }}
4747
4848
- name: Install dbt-oracle with core dependencies
4949
run: |
5050
python -m pip install --upgrade pip
51-
pip install pytest 'dbt-tests-adapter~=1.8,<1.9'
51+
pip install pytest 'dbt-tests-adapter~=1.11,<1.12'
5252
pip install -r requirements.txt
5353
pip install -e .
5454
@@ -66,10 +66,10 @@ jobs:
6666
DBT_ORACLE_PORT: 1521
6767
DBT_ORACLE_SCHEMA: DBT_TEST
6868
DBT_ORACLE_PASSWORD: ${{ secrets.DBT_ORACLE_PASSWORD }}
69-
DBT_ORACLE_DATABASE: XEPDB1
70-
DBT_ORACLE_SERVICE: XEPDB1
69+
DBT_ORACLE_DATABASE: FREEPDB1
70+
DBT_ORACLE_SERVICE: FREEPDB1
7171
DBT_ORACLE_PROTOCOL: tcp
72-
LD_LIBRARY_PATH: /opt/oracle/instantclient_21_6
72+
LD_LIBRARY_PATH: /opt/oracle/instantclient_23_7
7373
TNS_ADMIN: /opt/tns_admin
7474
DBT_TEST_USER_1: DBT_TEST_USER_1
7575
DBT_TEST_USER_2: DBT_TEST_USER_2
@@ -85,8 +85,8 @@ jobs:
8585
DBT_ORACLE_PORT: 1521
8686
DBT_ORACLE_SCHEMA: DBT_TEST
8787
DBT_ORACLE_PASSWORD: ${{ secrets.DBT_ORACLE_PASSWORD }}
88-
DBT_ORACLE_DATABASE: XEPDB1
89-
DBT_ORACLE_SERVICE: XEPDB1
88+
DBT_ORACLE_DATABASE: FREEPDB1
89+
DBT_ORACLE_SERVICE: FREEPDB1
9090
DBT_ORACLE_PROTOCOL: tcp
9191
DISABLE_OOB: on
9292
TNS_ADMIN: /opt/tns_admin

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Configuration variables
2-
VERSION=1.8.3
2+
VERSION=1.9.2
33
PROJ_DIR?=$(shell pwd)
44
VENV_DIR?=${PROJ_DIR}/.bldenv
55
BUILD_DIR=${PROJ_DIR}/build
66
DIST_DIR=${PROJ_DIR}/dist
7-
PYTHON_3=python3.9
7+
PYTHON_3=python3.12
88

99

1010
clean_venv:

dbt/adapters/oracle/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
version = "1.8.3"
17+
version = "1.9.1"

dbt/adapters/oracle/connection_helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class OracleNetConfig(dict):
7171
'wallet_password',
7272
'wallet_location',
7373
'expire_time',
74-
'https_proxy',
75-
'https_proxy_port',
7674
'retry_count',
7775
'retry_delay',
7876
'tcp_connect_timeout',

dbt/adapters/oracle/connections.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2023, Oracle and/or its affiliates.
2+
Copyright (c) 2025, Oracle and/or its affiliates.
33
Copyright (c) 2020, Vitor Avancini
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -120,6 +120,10 @@ class OracleAdapterCredentials(Credentials):
120120
# session info is stored in v$session for each dbt run
121121
session_info: Optional[Dict[str, str]] = field(default_factory=dict)
122122

123+
# read http proxy from profiles.yml
124+
https_proxy: Optional[str] = None
125+
https_proxy_port: Optional[int] = None
126+
123127

124128
_ALIASES = {
125129
'dbname': 'database',
@@ -208,11 +212,19 @@ def open(cls, connection):
208212
logger.debug(f"Attempting to connect using Oracle method: '{method}' "
209213
f"and dsn: '{dsn}'")
210214

211-
conn_config = {
212-
'user': credentials.user,
213-
'password': credentials.password,
214-
'dsn': dsn
215-
}
215+
if credentials.password is None:
216+
logger.debug("Password not supplied. "
217+
"Using external authentication")
218+
conn_config = {
219+
'externalauth': True,
220+
'dsn': dsn
221+
}
222+
else:
223+
conn_config = {
224+
'user': credentials.user,
225+
'password': credentials.password,
226+
'dsn': dsn
227+
}
216228

217229
if oracledb.__name__ == "oracledb":
218230
conn_config['connection_id_prefix'] = f'dbt-oracle-{dbt_version}-'
@@ -235,6 +247,11 @@ def open(cls, connection):
235247
elif purity == 'default':
236248
conn_config['purity'] = oracledb.ATTR_PURITY_DEFAULT
237249

250+
if credentials.https_proxy and credentials.https_proxy_port:
251+
conn_config['https_proxy'] = credentials.https_proxy
252+
conn_config['https_proxy_port'] = credentials.https_proxy_port
253+
254+
238255
if SQLNET_ORA_CONFIG is not None:
239256
conn_config.update(SQLNET_ORA_CONFIG)
240257

dbt/adapters/oracle/python_submissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def get_session_info(credentials):
159159
}
160160

161161
def schedule_async_job_and_wait_for_completion(self, data):
162-
logger.info(f"Running Python aysnc job using {data}")
162+
logger.info(f"Running Python async job using {data}")
163163
try:
164164
r = self.oml4py_client.request(method="POST",
165165
path=OML_DO_EVAL_API.format(script_name=self.py_q_script_name),

dbt/include/oracle/macros/adapters.sql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
{%- endif -%}
7272
{%- call statement('create_schema') -%}
7373
-- Noop for not breaking tests, oracle
74-
-- schemas are actualy users, we can't
74+
-- schemas are actually users, we can't
7575
-- create it here
7676
select 'a' from dual
7777
{%- endcall -%}
@@ -159,9 +159,9 @@
159159
{%- set sql = get_select_subquery(sql) %}
160160
{% endif %}
161161
{% if temporary -%} on commit preserve rows {%- endif %}
162+
{% if parallel %} parallel {{ parallel }}{% endif %}
162163
{% if not temporary -%}
163164
{% if partition_clause %} {{ partition_clause }} {% endif %}
164-
{% if parallel %} parallel {{ parallel }}{% endif %}
165165
{% if compression_clause %} {{ compression_clause }} {% endif %}
166166
{%- endif %}
167167
as
@@ -422,3 +422,13 @@
422422
{% set db_name = results.columns[0].values()[0] %}
423423
{{ return(db_name) }}
424424
{% endmacro %}
425+
426+
{% macro generate_insert_hint(parallel, insert_mode) %}
427+
{% if parallel and insert_mode == 'append' %}
428+
/*+parallel({{ parallel }}) append*/
429+
{% elif parallel %}
430+
/*+parallel({{ parallel }})*/
431+
{% elif insert_mode == 'append' %}
432+
/*+ append */
433+
{% endif %}
434+
{% endmacro %}

dbt/include/oracle/macros/materializations/incremental/strategies.sql

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,15 @@
9494
9595
{% macro oracle__get_incremental_append_sql(args_dict) %}
9696
{%- set parallel = config.get('parallel', none) -%}
97+
{%- set insert_mode = config.get('insert_mode', none) -%}
98+
{%- set insert_hint = generate_insert_hint(parallel, insert_mode) -%}
9799
{%- set dest_columns = args_dict["dest_columns"] -%}
98100
{%- set temp_relation = args_dict["temp_relation"] -%}
99101
{%- set target_relation = args_dict["target_relation"] -%}
100102
{%- set dest_column_names = dest_columns | map(attribute='name') | list -%}
101103
{%- set dest_cols_csv = get_quoted_column_csv(model, dest_column_names) -%}
102-
INSERT {% if parallel %} /*+PARALLEL({{ parallel }})*/ {% endif %} INTO {{ target_relation }} ({{ dest_cols_csv }})
104+
INSERT {{ insert_hint }}
105+
INTO {{ target_relation }} ({{ dest_cols_csv }})
103106
(
104107
SELECT {{ dest_cols_csv }}
105108
FROM {{ temp_relation }}
@@ -108,6 +111,8 @@
108111
109112
{% macro oracle__get_incremental_merge_sql(args_dict) %}
110113
{%- set parallel = config.get('parallel', none) -%}
114+
{%- set insert_mode = config.get('insert_mode', none) -%}
115+
{%- set insert_hint = generate_insert_hint(parallel, insert_mode) -%}
111116
{%- set dest_columns = args_dict["dest_columns"] -%}
112117
{%- set temp_relation = args_dict["temp_relation"] -%}
113118
{%- set target_relation = args_dict["target_relation"] -%}
@@ -138,7 +143,8 @@
138143
{% endfor -%}
139144
)
140145
{%- else -%}
141-
insert {% if parallel %} /*+parallel({{ parallel }})*/ {% endif %} into {{ target_relation }} ({{ dest_cols_csv }})
146+
insert {{ insert_hint }}
147+
into {{ target_relation }} ({{ dest_cols_csv }})
142148
(
143149
select {{ dest_cols_csv }}
144150
from {{ temp_relation }}
@@ -178,6 +184,8 @@
178184
179185
{% macro oracle__get_incremental_delete_insert_sql(args_dict) %}
180186
{%- set parallel = config.get('parallel', none) -%}
187+
{%- set insert_mode = config.get('insert_mode', none) -%}
188+
{%- set insert_hint = generate_insert_hint(parallel, insert_mode) -%}
181189
{%- set dest_columns = args_dict["dest_columns"] -%}
182190
{%- set temp_relation = args_dict["temp_relation"] -%}
183191
{%- set target_relation = args_dict["target_relation"] -%}
@@ -188,12 +196,14 @@
188196
{%- if unique_key or incremental_predicates -%}
189197
BEGIN
190198
EXECUTE IMMEDIATE '{{ oracle__get_delete_sql_for_delete_insert_strategy(target_relation, temp_relation, unique_key, incremental_predicates) }}';
191-
EXECUTE IMMEDIATE 'insert {% if parallel %} /*+parallel({{ parallel }})*/ {% endif %} into {{ target_relation }} ({{ dest_cols_csv }})(
199+
EXECUTE IMMEDIATE 'INSERT {{ insert_hint }}
200+
into {{ target_relation }} ({{ dest_cols_csv }})(
192201
select {{ dest_cols_csv }}
193202
from {{ temp_relation }})';
194203
END;
195204
{%- else -%}
196-
insert {% if parallel %} /*+parallel({{ parallel }})*/ {% endif %} into {{ target_relation }} ({{ dest_cols_csv }})
205+
insert {{ insert_hint }}
206+
into {{ target_relation }} ({{ dest_cols_csv }})
197207
(
198208
select {{ dest_cols_csv }}
199209
from {{ temp_relation }}

0 commit comments

Comments
 (0)