Skip to content

Release v1.3.1 changes #58

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 1 commit into from
Dec 14, 2022
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: 5 additions & 1 deletion dbt/adapters/oracle/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from dataclasses import dataclass, field
import enum
import time
import uuid

import dbt.exceptions
from dbt.adapters.base import Credentials
from dbt.adapters.sql import SQLConnectionManager
from dbt.contracts.connection import AdapterResponse
from dbt.events import AdapterLogger

from dbt.version import __version__ as dbt_version
from dbt.adapters.oracle.connection_helper import oracledb, SQLNET_ORA_CONFIG

logger = AdapterLogger("oracle")
Expand Down Expand Up @@ -177,6 +179,9 @@ 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()}'
connection.handle = handle
connection.state = 'open'
except oracledb.DatabaseError as e:
Expand Down Expand Up @@ -270,7 +275,6 @@ def add_query(

logger.debug(f'On {connection.name}: f{log_sql}')
pre = time.time()

cursor = connection.handle.cursor()
cursor.execute(sql, bindings)
connection.handle.commit()
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/oracle/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@

{% macro oracle__make_temp_relation(base_relation, suffix) %}
{% set dt = modules.datetime.datetime.now() %}
{% set dtstring = dt.strftime("%H%M%S") %}
{% set dtstring = dt.strftime("%H%M%S%f") %}
{% set tmp_identifier = 'o$pt_' ~ base_relation.identifier ~ dtstring %}
{% set tmp_relation = base_relation.incorporate(
path={"identifier": tmp_identifier, "schema": None}) -%}
Expand Down
20 changes: 20 additions & 0 deletions dbt/include/oracle/macros/materializations/snapshot/strategies.sql
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,23 @@
{%- endfor -%}
{{ return([ns.column_added, intersection]) }}
{%- endmacro %}

{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}
{% set primary_key = config['unique_key'] %}
{% set updated_at = config['updated_at'] %}
{% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}

{% set row_changed_expr -%}
({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})
{%- endset %}
{# updated_at should be cast as timestamp because in hash computation "CAST(date as VARCHAR)" truncates time fields #}
{% set scd_id_expr = snapshot_hash_arguments([primary_key, 'CAST(' ~ updated_at ~ ' AS TIMESTAMP)']) %}

{% do return({
"unique_key": primary_key,
"updated_at": updated_at,
"row_changed": row_changed_expr,
"scd_id": scd_id_expr,
"invalidate_hard_deletes": invalidate_hard_deletes
}) %}
{% endmacro %}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dbt-core==1.3.1
cx_Oracle==8.3.0
oracledb==1.2.0
oracledb==1.2.1

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ include_package_data = True
install_requires =
dbt-core==1.3.1
cx_Oracle==8.3.0
oracledb==1.2.0
oracledb==1.2.1
test_suite=tests
test_requires =
dbt-tests-adapter==1.3.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
requirements = [
"dbt-core==1.3.1",
"cx_Oracle==8.3.0",
"oracledb==1.2.0"
"oracledb==1.2.1"
]

test_requirements = [
Expand Down