-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Problem Description
In sdv-dev/SDV#2778, we are allowing for composite keys to be specified in the metadata. Although SDV Community won't be able to model composite keys, SDV Enterprise will have this capability. Therefore, a user might have real and synthetic data with composite keys.
In this case, the KeyUniqueness metric should be able to work with composite keys.
Expected behavior
Currently, this metric pd.Series objects that represent the primary and foreign keys. Instead of pd.Series, the metric should actually take in pd.DataFrame objects. This way, the user would be able to pass in more than one column.
(If there is a singular column, then it's easy enough to create a dataframe with only 1 column.)
from sdmetrics.single_column import KeyUniqueness
# current behavior: pass in pd.Series objects
KeyUniqueness.compute(
real_data=real_table['primary_key_name'],
synthetic_data=synthetic_table['primary_key_name'])
# expected behavior: pass in pd.DataFrame objects
KeyUniqueness.compute(
real_data=real_table[['primary_key_name']],
synthetic_data=synthetic_table[['primary_key_name']])
# the expected behavior then also supports composite keys
KeyUniqueness.compute(
real_data=real_table[['col1', 'col2']],
synthetic_data=synthetic_table[['col1', 'col2']])In the case of composite keys, the values in each single column are allowed to repeat. So the uniqueness should be based on all columns (as a group) rather than singular columns.
Additional context
This is a blocker for supporting composite keys in the reports. See #835.