Skip to content

v1.9.1 changes #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/scripts/create_new_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -Exeuo pipefail
# Parameters
DB_USER="${1}"
DB_PASSWORD="${2}"
TARGET_PDB="${3:-XEPDB1}"
TARGET_PDB="${3:-FREEPDB1}"

# Prepare container switch statement to create user in PDB.
ALTER_SESSION_CMD="ALTER SESSION SET CONTAINER=${TARGET_PDB};"
Expand All @@ -21,7 +21,7 @@ sqlplus -s / as sysdba << EOF
-- Exit on any errors
WHENEVER SQLERROR EXIT SQL.SQLCODE
${ALTER_SESSION_CMD}
CREATE USER ${DB_USER} IDENTIFIED BY "${DB_PASSWORD}" QUOTA UNLIMITED ON USERS;
GRANT ALL PRIVILEGES TO ${DB_USER};
CREATE USER ${DB_USER} IDENTIFIED BY "${DB_PASSWORD}" QUOTA UNLIMITED ON SYSTEM;
GRANT DB_DEVELOPER_ROLE TO ${DB_USER};
exit;
EOF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: dbt-tests-adapter
on: push

jobs:
oracle_xe_21_3:
dbt_oracle_adapter_tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
Expand All @@ -11,11 +11,11 @@ jobs:
python-version: ['3.9', '3.10', '3.11', '3.12']

services:
oracle_db_xe:
image: container-registry.oracle.com/database/express:21.3.0-xe
oracle_db:
image: container-registry.oracle.com/database/free:latest-lite
env:
ORACLE_PWD: ${{ secrets.DBT_ORACLE_PASSWORD }}
options: --name oracle_db_xe
options: --name oracle_db
ports:
- 1521:1521

Expand All @@ -36,19 +36,19 @@ jobs:
- name: Copy Create User script
run: |
chmod +x ${{ github.workspace }}/.github/scripts/create_new_user.sh
docker cp ${{ github.workspace }}/.github/scripts/create_new_user.sh oracle_db_xe:/home/oracle/create_new_user.sh
docker cp ${{ github.workspace }}/.github/scripts/create_new_user.sh oracle_db:/home/oracle/create_new_user.sh

- name: Create dbt test users
run: |
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_1 ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_2 ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db_xe /home/oracle/create_new_user.sh dbt_test_user_3 ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_1 ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_2 ${{ secrets.DBT_ORACLE_PASSWORD }}
docker exec oracle_db /home/oracle/create_new_user.sh dbt_test_user_3 ${{ secrets.DBT_ORACLE_PASSWORD }}

- name: Install dbt-oracle with core dependencies
run: |
python -m pip install --upgrade pip
pip install pytest 'dbt-tests-adapter~=1.10,<1.11'
pip install pytest 'dbt-tests-adapter~=1.11,<1.12'
pip install -r requirements.txt
pip install -e .

Expand All @@ -66,8 +66,8 @@ jobs:
DBT_ORACLE_PORT: 1521
DBT_ORACLE_SCHEMA: DBT_TEST
DBT_ORACLE_PASSWORD: ${{ secrets.DBT_ORACLE_PASSWORD }}
DBT_ORACLE_DATABASE: XEPDB1
DBT_ORACLE_SERVICE: XEPDB1
DBT_ORACLE_DATABASE: FREEPDB1
DBT_ORACLE_SERVICE: FREEPDB1
DBT_ORACLE_PROTOCOL: tcp
LD_LIBRARY_PATH: /opt/oracle/instantclient_23_7
TNS_ADMIN: /opt/tns_admin
Expand All @@ -85,8 +85,8 @@ jobs:
DBT_ORACLE_PORT: 1521
DBT_ORACLE_SCHEMA: DBT_TEST
DBT_ORACLE_PASSWORD: ${{ secrets.DBT_ORACLE_PASSWORD }}
DBT_ORACLE_DATABASE: XEPDB1
DBT_ORACLE_SERVICE: XEPDB1
DBT_ORACLE_DATABASE: FREEPDB1
DBT_ORACLE_SERVICE: FREEPDB1
DBT_ORACLE_PROTOCOL: tcp
DISABLE_OOB: on
TNS_ADMIN: /opt/tns_admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
{{ new_scd_id }} as {{ columns.dbt_scd_id }},
'True' as {{ columns.dbt_is_deleted }}
from snapshotted_data
left join deletes_source_data as source_data
left join deletes_source_data source_data
on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
where {{ unique_key_is_null(strategy.unique_key, "source_data") }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
limitations under the License.
#}
{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}
{% set check_cols_config = config['check_cols'] %}
{% set primary_key = config['unique_key'] %}
{% set check_cols_config = config.get('check_cols') %}
{% set primary_key = config.get('unique_key') %}
{% set hard_deletes = adapter.get_hard_deletes_behavior(config) %}
{% set invalidate_hard_deletes = hard_deletes == 'invalidate' %}

Expand Down
2 changes: 1 addition & 1 deletion dbt_adbs_test_project/models/promotion_costs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
#}
{{ config(materialized='table', grants = {'select': ['dbt_test_1']})}}
{{ config(materialized='table', grants = {'select': ['DBT_TEST_USER_1']})}}
with all_promo_costs as(
select * from {{ source('sh_database', 'promotions') }}
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dbt-common>=1.1.0,<2.0
dbt-adapters>=1.2.1,<2.0
dbt-core>=1.9.1,<2.0
oracledb==3.0.0
oracledb==3.1.0
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ tox
coverage
twine
pytest
dbt-tests-adapter~=1.10,<1.11
dbt-tests-adapter~=1.11,<1.12
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
dbt-common>=1.1.0,<2.0
dbt-adapters>=1.2.1,<2.0
dbt-core~=1.9,<1.10
oracledb==3.0.0
oracledb==3.1.0
test_suite=tests
test_requires =
dbt-tests-adapter~=1.10,<1.11
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dbt-common>=1.1.0,<2.0",
"dbt-adapters>=1.2.1,<2.0",
"dbt-core~=1.9,<1.10",
"oracledb==3.0.0"
"oracledb==3.1.0"
]

test_requirements = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2022, Oracle and/or its affiliates.
Copyright (c) 2025, Oracle and/or its affiliates.
Copyright (c) 2020, Vitor Avancini

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -57,6 +57,11 @@
"""

models__expected__unique_key_list__inplace_overwrite_sql = """
{{
config(
materialized='table'
)
}}
SELECT
'CT' AS state,
'Hartford' AS county,
Expand All @@ -72,9 +77,16 @@
SELECT 'NY','New York','Manhattan', TO_DATE('2021-04-01', 'YYYY-MM-DD') FROM DUAL
union all
SELECT 'PA','Philadelphia','Philadelphia', TO_DATE('2021-05-21', 'YYYY-MM-DD') FROM DUAL
union all
select 'CO','Denver',null,TO_DATE('2021-06-18', 'YYYY-MM-DD') FROM DUAL
"""

models__expected__one_str__overwrite_sql = """
{{
config(
materialized='table'
)
}}
SELECT
'CT' AS state,
'Hartford' AS county,
Expand All @@ -90,6 +102,8 @@
SELECT 'NY','New York','Manhattan', TO_DATE('2021-04-01', 'YYYY-MM-DD') FROM DUAL
union all
SELECT 'PA','Philadelphia','Philadelphia', TO_DATE('2021-05-21', 'YYYY-MM-DD') FROM DUAL
union all
select 'CO','Denver', null, TO_DATE('2021-06-18', 'YYYY-MM-DD') FROM DUAL
"""


Expand Down
4 changes: 2 additions & 2 deletions tests/functional/adapter/snapshots/test_invalidate_deletes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2022, Oracle and/or its affiliates.
Copyright (c) 2025, Oracle and/or its affiliates.
Copyright (c) 2020, Vitor Avancini

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,7 +34,7 @@
{% snapshot cc_all_snapshot %}
{{ config(
check_cols='all',
unique_key='id',
unique_key=['id'],
strategy='check',
target_database=database,
target_schema=schema,
Expand Down
60 changes: 58 additions & 2 deletions tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,50 @@
"""


cc_all_snapshot_sql = """
{% snapshot cc_all_snapshot %}
{{ config(
check_cols='all', unique_key=['id'], strategy='check',
target_database=database, target_schema=schema
) }}
select * from {{ ref(var('seed_name', 'base')) }}
{% endsnapshot %}
""".strip()

cc_name_snapshot_sql = """
{% snapshot cc_name_snapshot %}
{{ config(
check_cols=['name'], unique_key=['id'], strategy='check',
target_database=database, target_schema=schema
) }}
select * from {{ ref(var('seed_name', 'base')) }}
{% endsnapshot %}
""".strip()

cc_date_snapshot_sql = """
{% snapshot cc_date_snapshot %}
{{ config(
check_cols=['some_date'], unique_key=['id'], strategy='check',
target_database=database, target_schema=schema
) }}
select * from {{ ref(var('seed_name', 'base')) }}
{% endsnapshot %}
""".strip()

ts_snapshot_sql = """
{% snapshot ts_snapshot %}
{{ config(
strategy='timestamp',
unique_key=['id'],
updated_at='some_date',
target_database=database,
target_schema=schema,
)}}
select * from {{ ref(var('seed_name', 'base')) }}
{% endsnapshot %}
""".strip()


class TestSimpleMaterializationsOracle(BaseSimpleMaterializations):
pass

Expand Down Expand Up @@ -146,11 +190,23 @@ class TestGenericTestsOracle(BaseGenericTests):


class TestSnapshotCheckColsOracle(BaseSnapshotCheckCols):
pass

@pytest.fixture(scope="class")
def snapshots(self):
return {
"cc_all_snapshot.sql": cc_all_snapshot_sql,
"cc_date_snapshot.sql": cc_date_snapshot_sql,
"cc_name_snapshot.sql": cc_name_snapshot_sql,
}


class TestSnapshotTimestampOracle(BaseSnapshotTimestamp):
pass

@pytest.fixture(scope="class")
def snapshots(self):
return {
"ts_snapshot.sql": ts_snapshot_sql,
}


class TestBaseAdapterMethodOracle(BaseAdapterMethod):
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/adapter/test_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
my_snapshot_sql = """
{% snapshot my_snapshot %}
{{ config(
check_cols='all', unique_key='id', strategy='check',
check_cols='all', unique_key=['id'], strategy='check',
target_database=database, target_schema=schema
) }}
select 1 as id, cast('blue' as {{ type_string() }}) as color from dual
select 1 as id, cast('blue' as {{ type_string() }}) as color
{% endsnapshot %}
""".strip()

Expand Down