15
15
limitations under the License.
16
16
"""
17
17
from dataclasses import dataclass
18
- from typing import Dict , ClassVar
19
-
18
+ from typing import Dict , ClassVar , Optional
20
19
21
20
from dbt .adapters .base .column import Column
22
21
from dbt .adapters .oracle .keyword_catalog import KEYWORDS
@@ -36,17 +35,20 @@ class OracleColumn(Column):
36
35
STRING_DATATYPES = {'char' , 'nchar' , 'varchar' , 'varchar2' , 'nvarchar2' }
37
36
NUMBER_DATATYPES = {'number' , 'float' }
38
37
38
+ char_length_unit : Optional [str ] = None
39
+
39
40
@property
40
41
def data_type (self ) -> str :
41
42
if self .is_string ():
42
- return self .oracle_string_type (self .dtype , self .string_size ())
43
+ return self .oracle_string_type (self .dtype , self .string_size (), self . char_length_unit )
43
44
elif self .is_numeric ():
44
45
return self .numeric_type (self .dtype , self .numeric_precision , self .numeric_scale )
45
46
else :
46
47
return self .dtype
47
48
48
49
@classmethod
49
- def oracle_string_type (cls , dtype : str , size : int = None ):
50
+ def oracle_string_type (cls , dtype : str , size : int = None ,
51
+ char_length_unit : str = None ):
50
52
"""
51
53
- CHAR(SIZE)
52
54
- VARCHAR2(SIZE)
@@ -55,6 +57,8 @@ def oracle_string_type(cls, dtype: str, size: int = None):
55
57
"""
56
58
if size is None :
57
59
return dtype
60
+ elif char_length_unit and char_length_unit .upper () == 'C' :
61
+ return "{}({} CHAR)" .format (dtype , size )
58
62
else :
59
63
return "{}({})" .format (dtype , size )
60
64
0 commit comments