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

Commit b4541f5

Browse files
committed
Added some comments for Redshift
1 parent f521d8a commit b4541f5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

data_diff/database.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,13 @@ def normalize_value_by_type(self, value: str, coltype: ColType) -> str:
538538
if isinstance(coltype, TemporalType):
539539
if coltype.rounds:
540540
timestamp = f"{value}::timestamp(6)"
541+
# Get seconds since epoch. Redshift doesn't support milli- or micro-seconds.
541542
secs = f"timestamp 'epoch' + round(extract(epoch from {timestamp})::decimal(38)"
543+
# Get the milliseconds from timestamp.
542544
ms = f"extract(ms from {timestamp})"
545+
# Get the microseconds from timestamp, without the milliseconds!
543546
us = f"extract(us from {timestamp})"
547+
# epoch = Total time since epoch in microseconds.
544548
epoch = f"{secs}*1000000 + {ms}*1000 + {us}"
545549
timestamp6 = f"to_char({epoch}, -6+{coltype.precision}) * interval '0.000001 seconds', 'YYYY-mm-dd HH24:MI:SS.US')"
546550
else:

0 commit comments

Comments
 (0)