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

Commit 5057627

Browse files
authored
Merge pull request #780 from datafold/databricks_support_for_timestamp_ntz
add TIMESTAMP_NTZ for databricks
2 parents 37ded34 + 1aa3fd4 commit 5057627

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

data_diff/databases/databricks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Dialect(BaseDialect):
5050
"DECIMAL": Decimal,
5151
# Timestamps
5252
"TIMESTAMP": Timestamp,
53+
"TIMESTAMP_NTZ": Timestamp,
5354
# Text
5455
"STRING": Text,
5556
# Boolean
@@ -89,7 +90,8 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
8990
"""Databricks timestamp contains no more than 6 digits in precision"""
9091

9192
if coltype.rounds:
92-
timestamp = f"cast(round(unix_micros({value}) / 1000000, {coltype.precision}) * 1000000 as bigint)"
93+
# cast to timestamp due to unix_micros() requiring timestamp
94+
timestamp = f"cast(round(unix_micros(cast({value} as timestamp)) / 1000000, {coltype.precision}) * 1000000 as bigint)"
9395
return f"date_format(timestamp_micros({timestamp}), 'yyyy-MM-dd HH:mm:ss.SSSSSS')"
9496

9597
precision_format = "S" * coltype.precision + "0" * (6 - coltype.precision)

0 commit comments

Comments
 (0)