Skip to content

Commit 71c4306

Browse files
Merge pull request #59 from DataKitchen/release/5.0.2
Release/5.0.2
2 parents 01ea1da + 3856718 commit 71c4306

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "dataops-testgen"
11-
version = "5.0.1"
11+
version = "5.0.2"
1212
description = "DataKitchen's Data Quality DataOps TestGen"
1313
authors = [
1414
{ "name" = "DataKitchen, Inc.", "email" = "info@datakitchen.io" },

testgen/common/models/test_definition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def copy(
349349
target_table_name: str | None = None,
350350
target_column_name: str | None = None,
351351
) -> None:
352-
modified_columns = [cls.table_groups_id, cls.profile_run_id, cls.test_suite_id]
352+
modified_columns = [cls.table_groups_id, cls.profile_run_id, cls.test_suite_id, cls.last_auto_gen_date]
353353

354354
select_columns = [
355355
literal(target_table_group_id).label("table_groups_id"),
@@ -358,6 +358,7 @@ def copy(
358358
else_=None,
359359
).label("profile_run_id"),
360360
literal(target_test_suite_id).label("test_suite_id"),
361+
literal(None).label("last_auto_gen_date"),
361362
]
362363

363364
if target_table_name:

testgen/template/dbupgrade/0169_incremental_upgrade.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,50 @@ FROM test_results r
2020
WHERE d.last_auto_gen_date IS NOT NULL
2121
AND test_results.id = r.id;
2222

23+
-- Handle duplicates before creating unique indexes
24+
25+
UPDATE test_definitions
26+
SET last_auto_gen_date = NULL
27+
WHERE last_auto_gen_date IS NOT NULL
28+
AND table_name IS NULL
29+
AND column_name IS NULL
30+
AND id NOT IN (
31+
SELECT DISTINCT ON (test_suite_id, test_type, schema_name) id
32+
FROM test_definitions
33+
WHERE last_auto_gen_date IS NOT NULL
34+
AND table_name IS NULL
35+
AND column_name IS NULL
36+
ORDER BY test_suite_id, test_type, schema_name, last_auto_gen_date
37+
);
38+
39+
UPDATE test_definitions
40+
SET last_auto_gen_date = NULL
41+
WHERE last_auto_gen_date IS NOT NULL
42+
AND table_name IS NOT NULL
43+
AND column_name IS NULL
44+
AND id NOT IN (
45+
SELECT DISTINCT ON (test_suite_id, test_type, schema_name, table_name) id
46+
FROM test_definitions
47+
WHERE last_auto_gen_date IS NOT NULL
48+
AND table_name IS NOT NULL
49+
AND column_name IS NULL
50+
ORDER BY test_suite_id, test_type, schema_name, table_name, last_auto_gen_date
51+
);
52+
53+
UPDATE test_definitions
54+
SET last_auto_gen_date = NULL
55+
WHERE last_auto_gen_date IS NOT NULL
56+
AND table_name IS NOT NULL
57+
AND column_name IS NOT NULL
58+
AND id NOT IN (
59+
SELECT DISTINCT ON (test_suite_id, test_type, schema_name, table_name, column_name) id
60+
FROM test_definitions
61+
WHERE last_auto_gen_date IS NOT NULL
62+
AND table_name IS NOT NULL
63+
AND column_name IS NOT NULL
64+
ORDER BY test_suite_id, test_type, schema_name, table_name, column_name, last_auto_gen_date
65+
);
66+
2367
CREATE UNIQUE INDEX uix_td_autogen_schema
2468
ON test_definitions (test_suite_id, test_type, schema_name)
2569
WHERE last_auto_gen_date IS NOT NULL

0 commit comments

Comments
 (0)