Skip to content

Commit

Permalink
visualization to work with multi-foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Nov 2, 2023
1 parent 7522d31 commit 40d005c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def _get_table_relationships_plot(self, table_name):
"""
plot_data = self.get_details(table_name).copy()
column_name = 'Child → Parent Relationship'
plot_data[column_name] = plot_data['Child Table'] + ' → ' + plot_data['Parent Table']
plot_data[column_name] = (
plot_data['Child Table'] + ' (' + plot_data['Foreign Key'] + ') → ' +
plot_data['Parent Table']
)
plot_data = plot_data.drop(['Child Table', 'Parent Table'], axis=1)

average_score = round(plot_data['Score'].mean(), 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def test_get_details_with_table_name(self):
relationship_validity.details = pd.DataFrame({
'Child Table': ['users_child', 'sessions_child'],
'Parent Table': ['users_parent', 'sessions_parent'],
'Metric': ['RelationshipValidityShapeSimilarity', 'SomeOtherMetric'],
'Primary Key': ['user_id', 'user_id'],
'Foreign Key': ['user_id', 'user_id'],
'Metric': ['ReferentialIntegrity', 'CardinalityBoundaryAdherence'],
'Score': [1.0, 0.5],
'Error': [None, 'Some error']
})
Expand All @@ -244,7 +246,9 @@ def test_get_details_with_table_name(self):
assert details_users_child.equals(pd.DataFrame({
'Child Table': ['users_child'],
'Parent Table': ['users_parent'],
'Metric': ['RelationshipValidityShapeSimilarity'],
'Primary Key': ['user_id'],
'Foreign Key': ['user_id'],
'Metric': ['ReferentialIntegrity'],
'Score': [1.0],
'Error': [None]
}, index=[0]))
Expand All @@ -253,7 +257,9 @@ def test_get_details_with_table_name(self):
assert details_sessions_parent.equals(pd.DataFrame({
'Child Table': ['sessions_child'],
'Parent Table': ['sessions_parent'],
'Metric': ['SomeOtherMetric'],
'Primary Key': ['user_id'],
'Foreign Key': ['user_id'],
'Metric': ['CardinalityBoundaryAdherence'],
'Score': [0.5],
'Error': ['Some error']
}, index=[1]))
Expand All @@ -268,7 +274,9 @@ def test_get_table_relationships_plot(self):
instance.details = pd.DataFrame({
'Child Table': ['users_child', 'sessions_child'],
'Parent Table': ['users_parent', 'sessions_parent'],
'Metric': ['RelationshipValidityShapeSimilarity', 'SomeOtherMetric'],
'Primary Key': ['user_id', 'user_id'],
'Foreign Key': ['user_id', 'user_id'],
'Metric': ['ReferentialIntegrity', 'CardinalityBoundaryAdherence'],
'Score': [1.0, 0.5],
'Error': [None, 'Some error']
})
Expand All @@ -279,7 +287,7 @@ def test_get_table_relationships_plot(self):
# Assert
assert isinstance(fig, Figure)

expected_x = ['users_child → users_parent']
expected_x = ['users_child (user_id) → users_parent']
expected_y = [1.0]
expected_title = 'Data Diagnostic: Relationship Validity (Average Score=1.0)'

Expand Down

0 comments on commit 40d005c

Please sign in to comment.