|
10 | 10 |
|
11 | 11 | from runtype import dataclass
|
12 | 12 |
|
13 |
| -from data_diff.sqeleton.databases import Database, MySQL, BigQuery, Presto, Oracle, Snowflake, DbPath |
| 13 | +from data_diff.sqeleton.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DbPath |
14 | 14 | from data_diff.sqeleton.abcs import NumericType
|
15 | 15 | from data_diff.sqeleton.queries import (
|
16 | 16 | table,
|
|
25 | 25 | leftjoin,
|
26 | 26 | rightjoin,
|
27 | 27 | this,
|
| 28 | + when, |
28 | 29 | Compiler,
|
29 | 30 | )
|
30 |
| -from data_diff.sqeleton.queries.ast_classes import Concat, Count, Expr, Random, TablePath, Code, ITable |
| 31 | +from data_diff.sqeleton.queries.ast_classes import Concat, Count, Expr, Func, Random, TablePath, Code, ITable |
31 | 32 | from data_diff.sqeleton.queries.extras import NormalizeAsString
|
32 | 33 |
|
33 | 34 | from .info_tree import InfoTree
|
@@ -82,6 +83,12 @@ def _outerjoin(db: Database, a: ITable, b: ITable, keys1: List[str], keys2: List
|
82 | 83 |
|
83 | 84 | is_exclusive_a = and_(b[k] == None for k in keys2)
|
84 | 85 | is_exclusive_b = and_(a[k] == None for k in keys1)
|
| 86 | + |
| 87 | + if isinstance(db, MsSQL): |
| 88 | + # There is no "IS NULL" or "ISNULL()" as expressions, only as conditions. |
| 89 | + is_exclusive_a = when(is_exclusive_a).then(1).else_(0) |
| 90 | + is_exclusive_b = when(is_exclusive_b).then(1).else_(0) |
| 91 | + |
85 | 92 | if isinstance(db, Oracle):
|
86 | 93 | is_exclusive_a = bool_to_int(is_exclusive_a)
|
87 | 94 | is_exclusive_b = bool_to_int(is_exclusive_b)
|
@@ -342,7 +349,7 @@ def _count_diff_per_column(self, db, diff_rows, cols, is_diff_cols):
|
342 | 349 | self.stats["diff_counts"] = diff_counts
|
343 | 350 |
|
344 | 351 | def _sample_and_count_exclusive(self, db, diff_rows, a_cols, b_cols):
|
345 |
| - if isinstance(db, Oracle): |
| 352 | + if isinstance(db, (Oracle, MsSQL)): |
346 | 353 | exclusive_rows_query = diff_rows.where((this.is_exclusive_a == 1) | (this.is_exclusive_b == 1))
|
347 | 354 | else:
|
348 | 355 | exclusive_rows_query = diff_rows.where(this.is_exclusive_a | this.is_exclusive_b)
|
|
0 commit comments