@@ -48,14 +48,17 @@ def _validate_relationships(self, real_data, synthetic_data, metadata):
4848 parent_key = rel ['parent_primary_key' ]
4949 child = rel ['child_table_name' ]
5050 child_key = rel ['child_foreign_key' ]
51+ parent_key_str = f"'{ parent_key } '" if isinstance (parent_key , str ) else str (parent_key )
52+ child_key_str = f"'{ child_key } '" if isinstance (child_key , str ) else str (child_key )
5153 parent_primary_key = _cast_to_iterable (parent_key )
5254 child_foreign_key = _cast_to_iterable (child_key )
55+
5356 if len (parent_primary_key ) != len (child_foreign_key ):
5457 error_msg = (
5558 f"The '{ parent } ' table and '{ child } ' table cannot be merged "
5659 'for computing the cardinality. Please make sure the number of columns '
57- f'in the primary key ({ len ( parent_primary_key ) } ) matches the number of '
58- f'columns in the foreign key ({ len ( child_foreign_key ) } ).'
60+ f'in the primary key ({ parent_key_str } ) matches the number of '
61+ f'columns in the foreign key ({ child_key_str } ).'
5962 )
6063 raise ValueError (error_msg )
6164 parent_dtypes = real_data [rel ['parent_table_name' ]][parent_primary_key ].dtypes
@@ -64,17 +67,11 @@ def _validate_relationships(self, real_data, synthetic_data, metadata):
6467 if (parent_dtype == 'object' and child_dtype != 'object' ) or (
6568 parent_dtype != 'object' and child_dtype == 'object'
6669 ):
67- parent_key_str = (
68- parent_key if isinstance (parent_key , str ) else "', '" .join (parent_key )
69- )
70- child_key_str = (
71- child_key if isinstance (child_key , str ) else "', '" .join (child_key )
72- )
7370 error_msg = (
7471 f"The '{ parent } ' table and '{ child } ' table cannot be merged "
7572 'for computing the cardinality. Please make sure the primary key'
76- f" in '{ parent } ' (' { parent_key_str } ' ) and the foreign key in '{ child } '"
77- f" (' { child_key_str } ' ) have the same data types."
73+ f" in '{ parent } ' ({ parent_key_str } ) and the foreign key in '{ child } '"
74+ f' ( { child_key_str } ) have the same data types.'
7875 )
7976 raise ValueError (error_msg )
8077
0 commit comments