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

Commit 40b3c87

Browse files
authored
Merge pull request #829 from datafold/fix-nonstrict-type-mismatches
Tolerate column type mismatches in non-strict mode
2 parents 8ca8822 + 047502e commit 40b3c87

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

data_diff/hashdiff_tables.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ def _validate_and_adjust_columns(self, table1: TableSegment, table2: TableSegmen
111111
col1 = table1._schema[c1]
112112
col2 = table2._schema[c2]
113113
if isinstance(col1, PrecisionType):
114-
if strict and not isinstance(col2, PrecisionType):
115-
raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}")
114+
if not isinstance(col2, PrecisionType):
115+
if strict:
116+
raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}")
117+
else:
118+
continue
116119

117120
lowest = min(col1, col2, key=lambda col: col.precision)
118121

@@ -123,8 +126,11 @@ def _validate_and_adjust_columns(self, table1: TableSegment, table2: TableSegmen
123126
table2._schema[c2] = attrs.evolve(col2, precision=lowest.precision, rounds=lowest.rounds)
124127

125128
elif isinstance(col1, (NumericType, Boolean)):
126-
if strict and not isinstance(col2, (NumericType, Boolean)):
127-
raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}")
129+
if not isinstance(col2, (NumericType, Boolean)):
130+
if strict:
131+
raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}")
132+
else:
133+
continue
128134

129135
lowest = min(col1, col2, key=lambda col: col.precision)
130136

0 commit comments

Comments
 (0)