55import time
66from operator import attrgetter , methodcaller
77from collections import defaultdict
8- from typing import List , Tuple , Iterator , Optional
8+ from typing import List , Tuple , Iterator , Optional , Type
99import logging
1010from concurrent .futures import ThreadPoolExecutor
1111
1818 ArithUUID ,
1919 NumericType ,
2020 PrecisionType ,
21+ StringType ,
2122 UnknownColType ,
2223 Schema ,
2324 Schema_CaseInsensitive ,
@@ -295,7 +296,8 @@ def diff_tables(self, table1: TableSegment, table2: TableSegment) -> DiffResult:
295296 mins , maxs = zip (* key_ranges )
296297
297298 key_type = table1 ._schema ["id" ]
298- assert type (key_type ) == type (table2 ._schema ["id" ])
299+ key_type2 = table2 ._schema ["id" ]
300+ assert key_type .python_type is key_type2 .python_type
299301
300302 # We add 1 because our ranges are exclusive of the end (like in Python)
301303 min_key = min (map (key_type .python_type , mins ))
@@ -324,7 +326,7 @@ def _validate_and_adjust_columns(self, table1, table2):
324326 col2 = table2 ._schema [c ]
325327 if isinstance (col1 , PrecisionType ):
326328 if not isinstance (col2 , PrecisionType ):
327- raise TypeError (f"Incompatible types for column { c } : { col1 } <-> { col2 } " )
329+ raise TypeError (f"Incompatible types for column ' { c } ' : { col1 } <-> { col2 } " )
328330
329331 lowest = min (col1 , col2 , key = attrgetter ("precision" ))
330332
@@ -336,7 +338,7 @@ def _validate_and_adjust_columns(self, table1, table2):
336338
337339 elif isinstance (col1 , NumericType ):
338340 if not isinstance (col2 , NumericType ):
339- raise TypeError (f"Incompatible types for column { c } : { col1 } <-> { col2 } " )
341+ raise TypeError (f"Incompatible types for column ' { c } ' : { col1 } <-> { col2 } " )
340342
341343 lowest = min (col1 , col2 , key = attrgetter ("precision" ))
342344
@@ -346,6 +348,10 @@ def _validate_and_adjust_columns(self, table1, table2):
346348 table1 ._schema [c ] = col1 .replace (precision = lowest .precision )
347349 table2 ._schema [c ] = col2 .replace (precision = lowest .precision )
348350
351+ elif isinstance (col1 , StringType ):
352+ if not isinstance (col2 , StringType ):
353+ raise TypeError (f"Incompatible types for column '{ c } ': { col1 } <-> { col2 } " )
354+
349355 for t in [table1 , table2 ]:
350356 for c in t ._relevant_columns :
351357 ctype = t ._schema [c ]
0 commit comments