Skip to content

Commit 3c496c6

Browse files
author
ci bot
committed
Merge branch 'qa-fixes' into 'enterprise'
Misc QA fixes + doc updates See merge request dkinternal/testgen/dataops-testgen!446
2 parents 285e70b + ffb41a9 commit 3c496c6

21 files changed

Lines changed: 188 additions & 95 deletions

File tree

testgen/common/models/test_suite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def select_minimal_where(
101101

102102
@classmethod
103103
@st.cache_data(show_spinner=False)
104-
def select_summary(cls, project_code: str, table_group_id: str | UUID | None = None) -> Iterable[TestSuiteSummary]:
104+
def select_summary(cls, project_code: str, table_group_id: str | UUID | None = None, test_suite_name: str | None = None) -> Iterable[TestSuiteSummary]:
105105
if table_group_id and not is_uuid4(table_group_id):
106106
return []
107107

@@ -199,9 +199,10 @@ def select_summary(cls, project_code: str, table_group_id: str | UUID | None = N
199199
WHERE suites.is_monitor IS NOT TRUE
200200
AND suites.project_code = :project_code
201201
{"AND suites.table_groups_id = :table_group_id" if table_group_id else ""}
202+
{"AND suites.test_suite ILIKE :test_suite_name" if test_suite_name else ""}
202203
ORDER BY LOWER(suites.test_suite);
203204
"""
204-
params = {"project_code": project_code, "table_group_id": table_group_id}
205+
params = {"project_code": project_code, "table_group_id": table_group_id, "test_suite_name": f"%{test_suite_name}%" if test_suite_name else None}
205206
db_session = get_current_session()
206207
results = db_session.execute(text(query), params).mappings().all()
207208
return [TestSuiteSummary(**row) for row in results]

testgen/template/flavors/bigquery/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ SELECT
9999
WHEN SAFE_DIVIDE(SUM(CASE WHEN REGEXP_CONTAINS(`{COL_NAME}`, r'^(\\+1|1)?[ .-]?(\\([2-9][0-9]{2}\\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$')
100100
THEN 1 END), COUNT(`{COL_NAME}`)) > 0.8 THEN 'PHONE_USA'
101101
WHEN SAFE_DIVIDE(SUM(CASE WHEN REGEXP_CONTAINS(`{COL_NAME}`, r'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$')
102+
AND `{COL_NAME}` NOT LIKE '%://%'
102103
THEN 1 END), COUNT(`{COL_NAME}`)) > 0.9 THEN 'EMAIL'
103104
WHEN SAFE_DIVIDE(SUM(CASE WHEN TRANSLATE(`{COL_NAME}`, '012345678', '999999999') IN ('99999', '999999999', '99999-9999')
104105
THEN 1 END), COUNT(`{COL_NAME}`)) > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/databricks/profiling/project_profiling_query.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ SELECT
100100
THEN 1 END) AS FLOAT)/CAST(COUNT(`{COL_NAME}`) AS FLOAT) > 0.9 THEN 'STATE_USA'
101101
WHEN CAST(SUM( CASE WHEN `{COL_NAME}` RLIKE '\\+1\\s*\\(?\\d{3}\\)?[-. ]*\\d{3}[-. ]*\\d{4}'
102102
THEN 1 END) AS FLOAT)/CAST(COUNT(`{COL_NAME}`) AS FLOAT) > 0.9 THEN 'PHONE_USA'
103-
WHEN CAST(SUM( CASE WHEN `{COL_NAME}` RLIKE '[_a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z][a-zA-Z]+'
103+
WHEN CAST(SUM( CASE WHEN `{COL_NAME}` RLIKE '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$'
104+
AND `{COL_NAME}` NOT LIKE '%://%'
104105
THEN 1 END) AS FLOAT)/CAST(COUNT(`{COL_NAME}`) AS FLOAT) > 0.9 THEN 'EMAIL'
105106
WHEN CAST(SUM( CASE WHEN TRANSLATE(`{COL_NAME}`,'012345678','999999999') IN ('99999', '999999999', '99999-9999')
106107
THEN 1 END) AS FLOAT)/CAST(COUNT(`{COL_NAME}`) AS FLOAT) > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/mssql/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ SELECT
110110
OR ("{COL_NAME}" LIKE '[+]1%[0-9][0-9][0-9][-. ][0-9][0-9][0-9][-. ][0-9][0-9][0-9][0-9]' AND "{COL_NAME}" NOT LIKE '%[^0-9+-]%')
111111
THEN 1 END) AS FLOAT)/CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.8 THEN 'PHONE_USA'
112112
WHEN CAST(SUM(CASE WHEN "{COL_NAME}" LIKE '%[_a-zA-Z0-9.-]%@%[a-zA-Z0-9.-]%.[a-zA-Z][a-zA-Z]%'
113+
AND "{COL_NAME}" NOT LIKE '%://%'
113114
THEN 1 END) AS FLOAT)/CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.9 THEN 'EMAIL'
114115
WHEN CAST(SUM(CASE WHEN TRANSLATE("{COL_NAME}",'012345678','999999999') IN ('99999', '999999999', '99999-9999')
115116
THEN 1 END) AS FLOAT)/CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/oracle/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ FROM (
159159
WHEN SUM(CASE WHEN REGEXP_LIKE("{COL_NAME}", '^(\+1|1)?[ .-]?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$')
160160
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.8 THEN 'PHONE_USA'
161161
WHEN SUM(CASE WHEN REGEXP_LIKE("{COL_NAME}", '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$')
162+
AND "{COL_NAME}" NOT LIKE '%://%'
162163
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.9 THEN 'EMAIL'
163164
WHEN SUM(CASE WHEN TRANSLATE("{COL_NAME}",'012345678','999999999') IN ('99999', '999999999', '99999-9999')
164165
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/redshift/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SELECT
7070
WHEN SUM(CASE WHEN "{COL_NAME}" ~ '^(\\+1|1)?[ .-]?(\\([2-9][0-9]{2}\\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$'
7171
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.8 THEN 'PHONE_USA'
7272
WHEN SUM(CASE WHEN "{COL_NAME}" ~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$'
73+
AND "{COL_NAME}" NOT LIKE '%://%'
7374
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.9 THEN 'EMAIL'
7475
WHEN SUM(CASE WHEN TRANSLATE("{COL_NAME}",'012345678','999999999') IN ('99999', '999999999', '99999-9999')
7576
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/redshift_spectrum/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SELECT
7070
WHEN SUM(CASE WHEN "{COL_NAME}" ~ '^(\\+1|1)?[ .-]?(\\([2-9][0-9]{2}\\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$'
7171
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.8 THEN 'PHONE_USA'
7272
WHEN SUM(CASE WHEN "{COL_NAME}" ~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$'
73+
AND "{COL_NAME}" NOT LIKE '%://%'
7374
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.9 THEN 'EMAIL'
7475
WHEN SUM(CASE WHEN TRANSLATE("{COL_NAME}",'012345678','999999999') IN ('99999', '999999999', '99999-9999')
7576
THEN 1 END)::FLOAT/COUNT("{COL_NAME}")::FLOAT > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/sap_hana/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ SELECT
8787
WHEN SUM(CASE WHEN "{COL_NAME}" LIKE_REGEXPR '^(\+1|1)?[ .-]?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$'
8888
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.8 THEN 'PHONE_USA'
8989
WHEN SUM(CASE WHEN "{COL_NAME}" LIKE_REGEXPR '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$'
90+
AND "{COL_NAME}" NOT LIKE '%://%'
9091
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.9 THEN 'EMAIL'
9192
WHEN SUM(CASE WHEN REPLACE_REGEXPR('[0-9]' IN "{COL_NAME}" WITH '9') IN ('99999', '999999999', '99999-9999')
9293
THEN 1 ELSE 0 END) / NULLIF(COUNT("{COL_NAME}"), 0) > 0.9 THEN 'ZIP_USA'

testgen/template/flavors/snowflake/profiling/project_profiling_query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ SELECT
7979
WHEN CAST(SUM(CASE WHEN REGEXP_LIKE("{COL_NAME}"::VARCHAR, '^(\\+1|1)?[ .-]?(\\([2-9][0-9]{2}\\)|[2-9][0-9]{2})[ .-]?[2-9][0-9]{2}[ .-]?[0-9]{4}$')
8080
THEN 1 END) AS FLOAT) / CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.8 THEN 'PHONE_USA'
8181
WHEN CAST(SUM(CASE WHEN REGEXP_LIKE("{COL_NAME}"::VARCHAR, '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')
82+
AND "{COL_NAME}"::VARCHAR NOT LIKE '%://%'
8283
THEN 1 END) AS FLOAT) / CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.9 THEN 'EMAIL'
8384
WHEN CAST(SUM(CASE WHEN TRANSLATE("{COL_NAME}",'012345678','999999999') IN ('99999', '999999999', '99999-9999')
8485
THEN 1 END) AS FLOAT) / CAST(COUNT("{COL_NAME}") AS FLOAT) > 0.9 THEN 'ZIP_USA'

testgen/ui/components/frontend/js/data_profiling/metadata_tags.js

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Attribute } from '../components/attribute.js';
1515
import { Input } from '../components/input.js';
1616
import { Icon } from '../components/icon.js';
1717
import { withTooltip } from '../components/tooltip.js';
18-
import { emitEvent } from '../utils.js';
18+
import { emitEvent, loadStylesheet } from '../utils.js';
1919
import { RadioGroup } from '../components/radio_group.js';
2020
import { Checkbox } from '../components/checkbox.js';
2121
import { capitalize } from '../display_utils.js';
@@ -26,7 +26,7 @@ import { Alert } from '../components/alert.js';
2626

2727
const { div, span } = van.tags;
2828

29-
const attributeWidth = 300;
29+
const attributeWidth = 250;
3030
const descriptionWidth = 932;
3131
const multiEditWidth = 400;
3232

@@ -79,10 +79,12 @@ const TAG_HELP = {
7979
* @returns
8080
*/
8181
const MetadataTagsCard = (props, item) => {
82+
loadStylesheet('metadata-tags', stylesheet);
83+
8284
const title = `${item.type} Tags `;
8385
const attributes = [
8486
'critical_data_element',
85-
...(item.type === 'column' ? ['excluded_data_element', 'pii_flag'] : []),
87+
...(item.type === 'column' ? ['pii_flag', 'excluded_data_element'] : []),
8688
'description',
8789
...TAG_KEYS,
8890
].map(key => {
@@ -235,33 +237,40 @@ const InheritedIcon = (/** @type string */ inheritedFrom) => withTooltip(
235237
* @returns
236238
*/
237239
const CdeDisplay = (value, isColumn, isInherited) => {
240+
if (value) {
241+
return div(
242+
{ style: `width: ${attributeWidth}px` },
243+
span(
244+
{ class: 'flex-row fx-gap-1 metadata-badge cde' },
245+
Icon({ size: 24, classes: 'text-purple' }, 'star'),
246+
span(isColumn ? 'Critical data element' : 'All critical data elements'),
247+
(isColumn && isInherited) ? InheritedIcon('table') : null,
248+
),
249+
);
250+
}
238251
return span(
239252
{ class: 'flex-row fx-gap-1', style: `width: ${attributeWidth}px` },
240-
Icon(
241-
{ size: value ? 24 : 20, classes: value ? 'text-purple' : 'text-disabled' },
242-
value ? 'star' : 'cancel',
243-
),
244-
span(
245-
{ class: value ? '' : 'text-secondary' },
246-
isColumn
247-
? (value ? 'Critical data element' : 'Not a critical data element')
248-
: (value ? 'All critical data elements' : 'Not all critical data elements'),
249-
),
253+
Icon({ size: 20, classes: 'text-disabled' }, 'cancel'),
254+
span({ class: 'text-secondary' }, isColumn ? 'Not a critical data element' : 'Not all critical data elements'),
250255
(isColumn && isInherited) ? InheritedIcon('table') : null,
251256
);
252257
}
253258

254259
const XdeDisplay = (/** @type boolean */ value) => {
260+
if (value) {
261+
return div(
262+
{ style: `width: ${attributeWidth}px` },
263+
span(
264+
{ class: 'flex-row fx-gap-1 metadata-badge xde' },
265+
Icon({ size: 20, classes: 'text-brown' }, 'visibility_off'),
266+
span('Excluded data element'),
267+
),
268+
);
269+
}
255270
return span(
256271
{ class: 'flex-row fx-gap-1', style: `width: ${attributeWidth}px` },
257-
Icon(
258-
{ size: 20, classes: value ? 'text-brown' : 'text-disabled' },
259-
value ? 'visibility_off' : 'visibility',
260-
),
261-
span(
262-
{ class: value ? '' : 'text-secondary' },
263-
value ? 'Excluded data element' : 'Not an excluded data element',
264-
),
272+
Icon({ size: 20, classes: 'text-disabled' }, 'visibility'),
273+
span({ class: 'text-secondary' }, 'Not an excluded data element'),
265274
);
266275
}
267276

@@ -273,13 +282,13 @@ const PiiDisplay = (/** @type string|null */ value) => {
273282
const typeLabel = pii_type_map[type];
274283
caption = `${pii_risk_map[risk] ?? 'Moderate'} Risk${typeLabel ? ' - ' + typeLabel : ''}${detail && detail !== typeLabel ? ' / ' + detail : ''}`;
275284
}
276-
return span(
277-
{ class: 'flex-row fx-gap-1', style: `width: ${attributeWidth}px` },
278-
Icon({ size: 24, classes: 'text-orange' }, 'shield_person'),
279-
div(
280-
{ class: 'flex-column fx-gap-1' },
285+
return div(
286+
{ style: `width: ${attributeWidth}px` },
287+
span(
288+
{ class: 'flex-row fx-gap-1 metadata-badge pii' },
289+
Icon({ size: 21, classes: 'text-orange' }, 'shield_person'),
281290
span('PII data'),
282-
caption ? span({ class: 'text-caption' }, caption) : null,
291+
caption ? withTooltip(Icon({ size: 16 }, 'help'), { text: caption }) : null,
283292
),
284293
);
285294
}
@@ -300,8 +309,8 @@ const MetadataTagsMultiEdit = (props, selectedItems) => {
300309

301310
const attributes = [
302311
'critical_data_element',
303-
'excluded_data_element',
304312
'pii_flag',
313+
'excluded_data_element',
305314
...TAG_KEYS,
306315
].map(key => ({
307316
key,
@@ -451,4 +460,31 @@ const WarningDialog = (open, pendingAction, warnCde, warnPii) => {
451460
);
452461
};
453462

463+
const stylesheet = new CSSStyleSheet();
464+
stylesheet.replace(`
465+
.metadata-badge {
466+
display: inline-flex;
467+
padding: 4px 12px 4px 6px;
468+
border-radius: 15px;
469+
height: 30px;
470+
box-sizing: border-box;
471+
}
472+
473+
.metadata-badge.cde {
474+
background-color: rgba(171, 71, 188, 0.15);
475+
}
476+
477+
.metadata-badge.cde i {
478+
margin-top: -3px;
479+
}
480+
481+
.metadata-badge.pii {
482+
background-color: rgba(255, 152, 0, 0.15);
483+
}
484+
485+
.metadata-badge.xde {
486+
background-color: rgba(141, 110, 99, 0.15);
487+
}
488+
`);
489+
454490
export { MetadataTagsCard, MetadataTagsMultiEdit, TAG_KEYS };

0 commit comments

Comments
 (0)