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

Commit d411dfc

Browse files
committed
Added is_distinct_from() method
1 parent ed1dfda commit d411dfc

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

data_diff/databases/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None
270270
return f"LIMIT {limit}"
271271

272272
def concat(self, l: List[str]) -> str:
273+
assert len(l) > 1
273274
joined_exprs = ", ".join(l)
274275
return f"concat({joined_exprs})"
275276

277+
def is_distinct_from(self, a: str, b: str) -> str:
278+
return f"{a} is distinct from {b}"
279+
276280
def timestamp_value(self, t: DbTime) -> str:
277281
return f"'{t.isoformat()}'"
278282

data_diff/databases/database_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ def concat(self, l: List[str]) -> str:
149149
"Provide SQL for concatenating a bunch of column into a string"
150150
...
151151

152+
@abstractmethod
153+
def is_distinct_from(self, a: str, b: str) -> str:
154+
"Provide SQL for a comparison where NULL = NULL is true"
155+
...
156+
152157
@abstractmethod
153158
def timestamp_value(self, t: DbTime) -> str:
154159
"Provide SQL for the given timestamp value"

data_diff/databases/mysql.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
6969

7070
def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
7171
return f"TRIM(CAST({value} AS char))"
72+
73+
def is_distinct_from(self, a: str, b: str) -> str:
74+
return f"not ({a} <=> {b})"

0 commit comments

Comments
 (0)