Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 0a7e182

Browse files
committed
UUID - Added support for Oracle, redshift
1 parent f37f84c commit 0a7e182

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

data_diff/databases/oracle.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class Oracle(ThreadedDatabase):
1616
TYPE_CLASSES: Dict[str, type] = {
1717
"NUMBER": Decimal,
1818
"FLOAT": Float,
19+
# Text
20+
"CHAR": Text,
21+
"NCHAR": Text,
22+
"NVARCHAR2": Text,
23+
"VARCHAR2": Text,
1924
}
2025
ROUNDS_ON_PREC_LOSS = True
2126

@@ -97,3 +102,7 @@ def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None
97102
raise NotImplementedError("No support for OFFSET in query")
98103

99104
return f"FETCH NEXT {limit} ROWS ONLY"
105+
106+
def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
107+
# Cast is necessary for correct MD5 (trimming not enough)
108+
return f"CAST(TRIM({value}) AS VARCHAR(36))"

tests/test_database_types.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ def __iter__(self):
291291
"numeric",
292292
],
293293
"uuid": [
294-
"$uuid"
294+
"text",
295+
"varchar(100)",
296+
"char(100)",
295297
],
296298
},
297299
db.Oracle: {
@@ -310,7 +312,10 @@ def __iter__(self):
310312
"double precision",
311313
],
312314
"uuid": [
313-
"$uuid"
315+
"CHAR(100)",
316+
"VARCHAR(100)",
317+
"NCHAR(100)",
318+
"NVARCHAR2(100)",
314319
],
315320
},
316321
db.Presto: {
@@ -407,8 +412,10 @@ def _insert_to_table(conn, table, values):
407412
for j, sample in values:
408413
if isinstance(sample, (float, Decimal, int)):
409414
value = str(sample)
410-
else:
415+
elif isinstance(sample, datetime):
411416
value = f"timestamp '{sample}'"
417+
else:
418+
value = f"'{sample}'"
412419
selects.append(f"SELECT {j}, {value} FROM dual")
413420
insertion_query += " UNION ALL ".join(selects)
414421
else:

0 commit comments

Comments
 (0)