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

Commit 3474795

Browse files
author
Sergey Vasilyev
committed
Tolerate empty samples for textual/uuid PKs
1 parent 6c9ab5f commit 3474795

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

data_diff/databases/base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,7 @@ def _refine_coltypes(
10931093
list,
10941094
log_message=table_path,
10951095
)
1096-
if not samples_by_row:
1097-
raise ValueError(f"Table {table_path} is empty.")
1098-
1099-
samples_by_col = list(zip(*samples_by_row))
1100-
1096+
samples_by_col = list(zip(*samples_by_row)) if samples_by_row else [[]] * len(text_columns)
11011097
for col_name, samples in safezip(text_columns, samples_by_col):
11021098
uuid_samples = [s for s in samples if s and is_uuid(s)]
11031099

tests/test_diff_tables.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,12 @@ def setUp(self):
696696
self.differ = HashDiffer(bisection_factor=2)
697697

698698
def test_right_table_empty(self):
699-
self.assertRaises(ValueError, list, self.differ.diff_tables(self.a, self.b))
699+
# NotImplementedError: Cannot use a column of type Text(_notes=[]) as a key
700+
self.assertRaises(NotImplementedError, list, self.differ.diff_tables(self.a, self.b))
700701

701702
def test_left_table_empty(self):
702-
self.assertRaises(ValueError, list, self.differ.diff_tables(self.a, self.b))
703+
# NotImplementedError: Cannot use a column of type Text(_notes=[]) as a key
704+
self.assertRaises(NotImplementedError, list, self.differ.diff_tables(self.a, self.b))
703705

704706

705707
class TestInfoTree(DiffTestCase):

0 commit comments

Comments
 (0)