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

Commit d8be22b

Browse files
committed
Use parameters instead of hard value in md5_to_int for Databricks
1 parent 1f314b2 commit d8be22b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

data_diff/databases/databricks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import math
33

44
from .database_types import *
5-
from .base import Database, import_helper, _query_conn, parse_table_name
5+
from .base import MD5_HEXDIGITS, CHECKSUM_HEXDIGITS, Database, import_helper, _query_conn, parse_table_name
66

77

88
@import_helper("databricks")
@@ -61,7 +61,7 @@ def quote(self, s: str):
6161
return f"`{s}`"
6262

6363
def md5_to_int(self, s: str) -> str:
64-
return f"conv(substr(md5({s}), 18), 16, 10)"
64+
return f"conv(substr(md5({s}), {1+MD5_HEXDIGITS-CHECKSUM_HEXDIGITS}), 16, 10)"
6565

6666
def to_string(self, s: str) -> str:
6767
return f"cast({s} as string)"
@@ -70,7 +70,6 @@ def _convert_db_precision_to_digits(self, p: int) -> int:
7070
# Subtracting 2 due to wierd precision issues in Databricks for the FLOAT type
7171
return super()._convert_db_precision_to_digits(p) - 2
7272

73-
7473
def query_table_schema(self, path: DbPath, filter_columns: Optional[Sequence[str]] = None) -> Dict[str, ColType]:
7574
# Databricks has INFORMATION_SCHEMA only for Databricks Runtime, not for Databricks SQL.
7675
# https://docs.databricks.com/spark/latest/spark-sql/language-manual/information-schema/columns.html

0 commit comments

Comments
 (0)