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

Commit e68def8

Browse files
committed
fix hardcoded offsets in mssql and snowflake
1 parent 98a6e38 commit e68def8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

data_diff/databases/mssql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
CHECKSUM_HEXDIGITS,
88
Mixin_OptimizerHints,
99
Mixin_RandomSample,
10+
CHECKSUM_OFFSET,
1011
QueryError,
1112
ThreadedDatabase,
1213
import_helper,
@@ -60,8 +61,7 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
6061
@attrs.define(frozen=False)
6162
class Mixin_MD5(AbstractMixin_MD5):
6263
def md5_as_int(self, s: str) -> str:
63-
offset = 549755813887
64-
return f"convert(bigint, convert(varbinary, '0x' + RIGHT(CONVERT(NVARCHAR(32), HashBytes('MD5', {s}), 2), {CHECKSUM_HEXDIGITS}), 1)) - {offset}"
64+
return f"convert(bigint, convert(varbinary, '0x' + RIGHT(CONVERT(NVARCHAR(32), HashBytes('MD5', {s}), 2), {CHECKSUM_HEXDIGITS}), 1)) - {CHECKSUM_OFFSET}"
6565

6666

6767
@attrs.define(frozen=False)

data_diff/databases/snowflake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import_helper,
3131
CHECKSUM_MASK,
3232
ThreadLocalInterpreter,
33+
CHECKSUM_OFFSET,
3334
Mixin_RandomSample,
3435
)
3536

@@ -46,8 +47,7 @@ def import_snowflake():
4647
@attrs.define(frozen=False)
4748
class Mixin_MD5(AbstractMixin_MD5):
4849
def md5_as_int(self, s: str) -> str:
49-
offset = 549755813887
50-
return f"BITAND(md5_number_lower64({s}), {CHECKSUM_MASK}) - {offset}"
50+
return f"BITAND(md5_number_lower64({s}), {CHECKSUM_MASK}) - {CHECKSUM_OFFSET}"
5151

5252

5353
@attrs.define(frozen=False)

0 commit comments

Comments
 (0)