Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configuration variables
VERSION=1.9.3
VERSION=1.9.4
PROJ_DIR?=$(shell pwd)
VENV_DIR?=${PROJ_DIR}/.bldenv
BUILD_DIR=${PROJ_DIR}/build
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/oracle/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
version = "1.9.3"
version = "1.9.4"
12 changes: 8 additions & 4 deletions dbt/adapters/oracle/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
limitations under the License.
"""
from dataclasses import dataclass
from typing import Dict, ClassVar

from typing import Dict, ClassVar, Optional

from dbt.adapters.base.column import Column
from dbt.adapters.oracle.keyword_catalog import KEYWORDS
Expand All @@ -36,17 +35,20 @@ class OracleColumn(Column):
STRING_DATATYPES = {'char', 'nchar', 'varchar', 'varchar2', 'nvarchar2'}
NUMBER_DATATYPES = {'number', 'float'}

char_length_unit: Optional[str] = None

@property
def data_type(self) -> str:
if self.is_string():
return self.oracle_string_type(self.dtype, self.string_size())
return self.oracle_string_type(self.dtype, self.string_size(), self.char_length_unit)
elif self.is_numeric():
return self.numeric_type(self.dtype, self.numeric_precision, self.numeric_scale)
else:
return self.dtype

@classmethod
def oracle_string_type(cls, dtype: str, size: int = None):
def oracle_string_type(cls, dtype: str, size: int = None,
char_length_unit: str = None):
"""
- CHAR(SIZE)
- VARCHAR2(SIZE)
Expand All @@ -55,6 +57,8 @@ def oracle_string_type(cls, dtype: str, size: int = None):
"""
if size is None:
return dtype
elif char_length_unit and char_length_unit.upper() == 'C':
return "{}({} CHAR)".format(dtype, size)
else:
return "{}({})".format(dtype, size)

Expand Down
3 changes: 2 additions & 1 deletion dbt/include/oracle/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@
data_type as "type",
char_length as "character_maximum_length",
numeric_precision as "numeric_precision",
numeric_scale as "numeric_scale"
numeric_scale as "numeric_scale",
char_used as "char_length_unit"
from columns
where upper(table_name) = upper('{{ relation.identifier }}')
{% if relation.schema %}
Expand Down
9 changes: 7 additions & 2 deletions dbt/include/oracle/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@
columns.column_name as "column_name",
ordinal_position as "column_index",
case
when data_type like '%CHAR%'
then data_type || '(' || cast(char_length as varchar(10)) || ')'
when data_type like '%CHAR%' then
CASE
WHEN char_used = 'C' THEN
data_type || '(' || cast(char_length as varchar(10)) || ' CHAR )'
ELSE
data_type || '(' || cast(char_length as varchar(10)) || ')'
END
else data_type
end as "column_type",
all_col_comments.comments as "column_comment",
Expand Down
4 changes: 2 additions & 2 deletions dbt_adbs_test_project/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ seeds:
seed_with_empty_col:
+column_types:
id: number
first_name: varchar2(16)
last_name: varchar2(16)
first_name: varchar2(16 char)
last_name: varchar2(16 char)
email: varchar2(26)
gender: varchar2(16)
age: number
Expand Down
1 change: 1 addition & 0 deletions dbt_adbs_test_project/models/sales_internet_mv.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
#}
{# Sales MV #}
{{ config(materialized='materialized_view', persist_docs={"relation": true, "columns": true}) }}
select * from {{ source('sh_database', 'sales') }}
where channel_id = 5
4 changes: 2 additions & 2 deletions 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.3,<2.0
oracledb==3.2.0
dbt-core~=1.10,<1.11
oracledb==3.3.0
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = dbt-oracle
version = 1.9.3
version = 1.9.4
description = dbt (data build tool) adapter for Oracle Autonomous Database
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -34,7 +34,7 @@ include_package_data = True
install_requires =
dbt-common>=1.1.0,<2.0
dbt-adapters>=1.2.1,<2.0
dbt-core~=1.9,<1.10
dbt-core~=1.10,<1.11
oracledb==3.2.0
test_suite=tests
test_requires =
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
requirements = [
"dbt-common>=1.1.0,<2.0",
"dbt-adapters>=1.2.1,<2.0",
"dbt-core~=1.9,<1.10",
"oracledb==3.2.0"
"dbt-core~=1.10,<1.11",
"oracledb==3.3.0"
]

test_requirements = [
Expand All @@ -61,7 +61,7 @@

url = 'https://github.com/oracle/dbt-oracle'

VERSION = '1.9.3'
VERSION = '1.9.4'
setup(
author="Oracle",
python_requires='>=3.9',
Expand Down