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

Commit 7e0770e

Browse files
committed
Small additions
1 parent 4cdf389 commit 7e0770e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

data_diff/diff_tables.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .databases.base import Database
1919
from .databases.database_types import (
2020
ArithUUID,
21+
IKey,
2122
NumericType,
2223
PrecisionType,
2324
StringType,
@@ -212,6 +213,8 @@ def count_and_checksum(self) -> Tuple[int, int]:
212213
"We recommend increasing --bisection-factor or decreasing --threads."
213214
)
214215

216+
if count:
217+
assert checksum, (count, checksum)
215218
return count or 0, checksum if checksum is None else int(checksum)
216219

217220
def query_key_range(self) -> Tuple[int, int]:
@@ -306,6 +309,10 @@ def diff_tables(self, table1: TableSegment, table2: TableSegment) -> DiffResult:
306309

307310
key_type = table1._schema[table1.key_column]
308311
key_type2 = table2._schema[table2.key_column]
312+
if not isinstance(key_type, IKey):
313+
raise NotImplementedError(f"Cannot use column of type {key_type} as a key")
314+
if not isinstance(key_type2, IKey):
315+
raise NotImplementedError(f"Cannot use column of type {key_type2} as a key")
309316
assert key_type.python_type is key_type2.python_type
310317

311318
# We add 1 because our ranges are exclusive of the end (like in Python)

data_diff/sql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ class Checksum(Sql):
121121

122122
def compile(self, c: Compiler):
123123
if len(self.exprs) > 1:
124-
compiled_exprs = ", ".join(f"coalesce({c.compile(expr)}, 'null')" for expr in self.exprs)
124+
compiled_exprs = ", ".join(f"coalesce({c.compile(expr)}, '<null>')" for expr in self.exprs)
125125
expr = f"concat({compiled_exprs})"
126126
else:
127+
# No need to coalesce - safe to assume that key cannot be null
127128
(expr,) = self.exprs
128129
expr = c.compile(expr)
129130
md5 = c.database.md5_to_int(expr)

0 commit comments

Comments
 (0)