|
6 | 6 |
|
7 | 7 | import pandas as pd |
8 | 8 | import streamlit as st |
9 | | -from sqlalchemy import asc, func, tuple_ |
| 9 | +from sqlalchemy import and_, asc, func, or_, tuple_ |
10 | 10 | from streamlit.delta_generator import DeltaGenerator |
11 | 11 | from streamlit_extras.no_default_selectbox import selectbox |
12 | 12 |
|
@@ -1184,13 +1184,16 @@ def get_test_definitions_collision( |
1184 | 1184 | target_table_group_id: str, |
1185 | 1185 | target_test_suite_id: str, |
1186 | 1186 | ) -> pd.DataFrame: |
| 1187 | + table_tests = [(item["table_name"], item["test_type"]) for item in test_definitions if item["column_name"] is None] |
| 1188 | + column_tests = [(item["table_name"], item["column_name"], item["test_type"]) for item in test_definitions if item["column_name"] is not None] |
1187 | 1189 | results = TestDefinition.select_minimal_where( |
1188 | 1190 | TestDefinition.table_groups_id == target_table_group_id, |
1189 | 1191 | TestDefinition.test_suite_id == target_test_suite_id, |
1190 | 1192 | TestDefinition.last_auto_gen_date.isnot(None), |
1191 | | - tuple_(TestDefinition.table_name, TestDefinition.column_name, TestDefinition.test_type).in_( |
1192 | | - [(item["table_name"], item["column_name"], item["test_type"]) for item in test_definitions] |
1193 | | - ), |
| 1193 | + or_( |
| 1194 | + tuple_(TestDefinition.table_name, TestDefinition.column_name, TestDefinition.test_type).in_(column_tests), |
| 1195 | + and_(tuple_(TestDefinition.table_name, TestDefinition.test_type).in_(table_tests), TestDefinition.column_name.is_(None)), |
| 1196 | + ) |
1194 | 1197 | ) |
1195 | 1198 | return to_dataframe(results, TestDefinitionMinimal.columns()) |
1196 | 1199 |
|
|
0 commit comments