dataops-testgen 2.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. dataops_testgen-2.2.0.dist-info/LICENSE +203 -0
  2. dataops_testgen-2.2.0.dist-info/METADATA +287 -0
  3. dataops_testgen-2.2.0.dist-info/NOTICE +5 -0
  4. dataops_testgen-2.2.0.dist-info/RECORD +270 -0
  5. dataops_testgen-2.2.0.dist-info/WHEEL +5 -0
  6. dataops_testgen-2.2.0.dist-info/entry_points.txt +2 -0
  7. dataops_testgen-2.2.0.dist-info/top_level.txt +1 -0
  8. testgen/__init__.py +0 -0
  9. testgen/__main__.py +770 -0
  10. testgen/commands/__init__.py +0 -0
  11. testgen/commands/queries/__init__.py +0 -0
  12. testgen/commands/queries/execute_cat_tests_query.py +95 -0
  13. testgen/commands/queries/execute_tests_query.py +160 -0
  14. testgen/commands/queries/generate_tests_query.py +94 -0
  15. testgen/commands/queries/profiling_query.py +366 -0
  16. testgen/commands/queries/test_parameter_validation_query.py +88 -0
  17. testgen/commands/run_execute_cat_tests.py +162 -0
  18. testgen/commands/run_execute_tests.py +168 -0
  19. testgen/commands/run_generate_tests.py +107 -0
  20. testgen/commands/run_get_entities.py +122 -0
  21. testgen/commands/run_launch_db_config.py +84 -0
  22. testgen/commands/run_observability_exporter.py +330 -0
  23. testgen/commands/run_profiling_bridge.py +495 -0
  24. testgen/commands/run_quick_start.py +168 -0
  25. testgen/commands/run_setup_profiling_tools.py +96 -0
  26. testgen/commands/run_test_definition.py +146 -0
  27. testgen/commands/run_test_parameter_validation.py +135 -0
  28. testgen/commands/run_upgrade_db_config.py +156 -0
  29. testgen/common/__init__.py +8 -0
  30. testgen/common/clean_sql.py +53 -0
  31. testgen/common/credentials.py +25 -0
  32. testgen/common/database/__init__.py +0 -0
  33. testgen/common/database/database_service.py +629 -0
  34. testgen/common/database/flavor/__init__.py +0 -0
  35. testgen/common/database/flavor/flavor_service.py +75 -0
  36. testgen/common/database/flavor/mssql_flavor_service.py +34 -0
  37. testgen/common/database/flavor/postgresql_flavor_service.py +5 -0
  38. testgen/common/database/flavor/redshift_flavor_service.py +22 -0
  39. testgen/common/database/flavor/snowflake_flavor_service.py +69 -0
  40. testgen/common/database/flavor/trino_flavor_service.py +21 -0
  41. testgen/common/date_service.py +68 -0
  42. testgen/common/display_service.py +85 -0
  43. testgen/common/docker_service.py +76 -0
  44. testgen/common/encrypt.py +55 -0
  45. testgen/common/get_pipeline_parms.py +57 -0
  46. testgen/common/logs.py +79 -0
  47. testgen/common/process_service.py +62 -0
  48. testgen/common/read_file.py +69 -0
  49. testgen/settings.py +440 -0
  50. testgen/template/dbsetup/010_create_base_schema.sql +2 -0
  51. testgen/template/dbsetup/020_create_standard_functions_sprocs.sql +179 -0
  52. testgen/template/dbsetup/030_initialize_new_schema_structure.sql +735 -0
  53. testgen/template/dbsetup/040_populate_new_schema_project.sql +59 -0
  54. testgen/template/dbsetup/050_populate_new_schema_metadata.sql +1517 -0
  55. testgen/template/dbsetup/060_create_standard_views.sql +248 -0
  56. testgen/template/dbsetup/070_create_default_users.sql +17 -0
  57. testgen/template/dbsetup/075_grant_role_rights.sql +43 -0
  58. testgen/template/dbsetup/080_set_current_revision.sql +5 -0
  59. testgen/template/dbupgrade/0100_incremental_upgrade.sql +5 -0
  60. testgen/template/dbupgrade/0101_incremental_upgrade.sql +15 -0
  61. testgen/template/dbupgrade/0102_incremental_upgrade.sql +4 -0
  62. testgen/template/dbupgrade/0103_incremental_upgrade.sql +22 -0
  63. testgen/template/dbupgrade/0104_incremental_upgrade.sql +44 -0
  64. testgen/template/dbupgrade/0105_incremental_upgrade.sql +1 -0
  65. testgen/template/dbupgrade/0106_incremental_upgrade.sql +5 -0
  66. testgen/template/dbupgrade/0107_incremental_upgrade.sql +3 -0
  67. testgen/template/dbupgrade_helpers/get_tg_revision.sql +2 -0
  68. testgen/template/exec_cat_tests/ex_cat_build_agg_table_tests.sql +116 -0
  69. testgen/template/exec_cat_tests/ex_cat_get_distinct_tables.sql +11 -0
  70. testgen/template/exec_cat_tests/ex_cat_results_parse.sql +69 -0
  71. testgen/template/exec_cat_tests/ex_cat_retrieve_agg_test_parms.sql +6 -0
  72. testgen/template/exec_cat_tests/ex_cat_test_query.sql +8 -0
  73. testgen/template/execution/ex_finalize_test_run_results.sql +37 -0
  74. testgen/template/execution/ex_get_tests_non_cat.sql +47 -0
  75. testgen/template/execution/ex_update_test_record_in_testrun_table.sql +27 -0
  76. testgen/template/execution/ex_write_test_record_to_testrun_table.sql +6 -0
  77. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_no_drops_generic.sql +48 -0
  78. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_num_incr_generic.sql +34 -0
  79. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_above_generic.sql +49 -0
  80. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_within_generic.sql +49 -0
  81. testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_same_generic.sql +49 -0
  82. testgen/template/flavors/generic/exec_query_tests/ex_custom_query_generic.sql +39 -0
  83. testgen/template/flavors/generic/exec_query_tests/ex_data_match_2way_generic.sql +58 -0
  84. testgen/template/flavors/generic/exec_query_tests/ex_data_match_generic.sql +44 -0
  85. testgen/template/flavors/generic/exec_query_tests/ex_prior_match_generic.sql +37 -0
  86. testgen/template/flavors/generic/exec_query_tests/ex_relative_entropy_generic.sql +53 -0
  87. testgen/template/flavors/generic/exec_query_tests/ex_window_match_no_drops_generic.sql +46 -0
  88. testgen/template/flavors/generic/exec_query_tests/ex_window_match_same_generic.sql +59 -0
  89. testgen/template/flavors/generic/profiling/contingency_counts.sql +3 -0
  90. testgen/template/flavors/generic/validate_tests/ex_get_project_column_list_generic.sql +3 -0
  91. testgen/template/flavors/mssql/exec_query_tests/ex_relative_entropy_mssql.sql +53 -0
  92. testgen/template/flavors/mssql/profiling/project_ddf_query_mssql.sql +35 -0
  93. testgen/template/flavors/mssql/profiling/project_profiling_query_mssql.yaml +246 -0
  94. testgen/template/flavors/mssql/profiling/project_secondary_profiling_query_mssql.sql +36 -0
  95. testgen/template/flavors/mssql/setup_profiling_tools/00_drop_existing_functions_mssql.sql +8 -0
  96. testgen/template/flavors/mssql/setup_profiling_tools/01_create_functions_mssql.sql +12 -0
  97. testgen/template/flavors/mssql/setup_profiling_tools/02_create_functions_mssql.sql +54 -0
  98. testgen/template/flavors/mssql/setup_profiling_tools/create_qc_schema_mssql.sql +4 -0
  99. testgen/template/flavors/mssql/setup_profiling_tools/grant_execute_privileges_mssql.sql +1 -0
  100. testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_no_drops_postgresql.sql +46 -0
  101. testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_same_postgresql.sql +59 -0
  102. testgen/template/flavors/postgresql/profiling/project_ddf_query_postgresql.sql +42 -0
  103. testgen/template/flavors/postgresql/profiling/project_profiling_query_postgresql.yaml +225 -0
  104. testgen/template/flavors/postgresql/profiling/project_secondary_profiling_query_postgresql.sql +28 -0
  105. testgen/template/flavors/postgresql/setup_profiling_tools/create_functions_postgresql.sql +157 -0
  106. testgen/template/flavors/postgresql/setup_profiling_tools/create_qc_schema_postgresql.sql +1 -0
  107. testgen/template/flavors/postgresql/setup_profiling_tools/grant_execute_privileges_postgresql.sql +2 -0
  108. testgen/template/flavors/redshift/profiling/project_ddf_query_redshift.sql +38 -0
  109. testgen/template/flavors/redshift/profiling/project_profiling_query_redshift.yaml +221 -0
  110. testgen/template/flavors/redshift/profiling/project_secondary_profiling_query_redshift.sql +29 -0
  111. testgen/template/flavors/redshift/setup_profiling_tools/create_functions_redshift.sql +115 -0
  112. testgen/template/flavors/redshift/setup_profiling_tools/create_qc_schema_redshift.sql +1 -0
  113. testgen/template/flavors/redshift/setup_profiling_tools/grant_execute_privileges_redshift.sql +2 -0
  114. testgen/template/flavors/snowflake/profiling/project_ddf_query_snowflake.sql +38 -0
  115. testgen/template/flavors/snowflake/profiling/project_profiling_query_snowflake.yaml +220 -0
  116. testgen/template/flavors/snowflake/profiling/project_secondary_profiling_query_snowflake.sql +29 -0
  117. testgen/template/flavors/snowflake/setup_profiling_tools/create_functions_snowflake.sql +69 -0
  118. testgen/template/flavors/snowflake/setup_profiling_tools/create_qc_schema_snowflake.sql +1 -0
  119. testgen/template/flavors/snowflake/setup_profiling_tools/grant_execute_privileges_snowflake.sql +6 -0
  120. testgen/template/flavors/trino/profiling/project_profiling_query_trino.yaml +219 -0
  121. testgen/template/flavors/trino/setup_profiling_tools/create_functions_trino.sql +92 -0
  122. testgen/template/flavors/trino/setup_profiling_tools/create_qc_schema_trino.sql +1 -0
  123. testgen/template/gen_funny_cat_tests/gen_test_constant.sql +104 -0
  124. testgen/template/gen_funny_cat_tests/gen_test_distinct_value_ct.sql +98 -0
  125. testgen/template/gen_funny_cat_tests/gen_test_row_ct.sql +57 -0
  126. testgen/template/gen_funny_cat_tests/gen_test_row_ct_pct.sql +59 -0
  127. testgen/template/generation/gen_delete_old_tests.sql +5 -0
  128. testgen/template/generation/gen_insert_test_suite.sql +5 -0
  129. testgen/template/generation/gen_retrieve_or_insert_test_suite.sql +58 -0
  130. testgen/template/generation/gen_standard_test_type_list.sql +13 -0
  131. testgen/template/generation/gen_standard_tests.sql +48 -0
  132. testgen/template/get_entities/get_connection.sql +21 -0
  133. testgen/template/get_entities/get_connections_list.sql +9 -0
  134. testgen/template/get_entities/get_latest.sql +4 -0
  135. testgen/template/get_entities/get_profile.sql +12 -0
  136. testgen/template/get_entities/get_profile_info.sql +17 -0
  137. testgen/template/get_entities/get_profile_list.sql +17 -0
  138. testgen/template/get_entities/get_profile_screen.sql +275 -0
  139. testgen/template/get_entities/get_project_list.sql +6 -0
  140. testgen/template/get_entities/get_table_group_list.sql +10 -0
  141. testgen/template/get_entities/get_test_generation_list.sql +18 -0
  142. testgen/template/get_entities/get_test_info.sql +41 -0
  143. testgen/template/get_entities/get_test_results_for_run_cli.sql +16 -0
  144. testgen/template/get_entities/get_test_run_list.sql +24 -0
  145. testgen/template/get_entities/get_test_suite.sql +13 -0
  146. testgen/template/get_entities/get_test_suite_list.sql +18 -0
  147. testgen/template/get_entities/list_test_types.sql +4 -0
  148. testgen/template/observability/get_event_data.sql +23 -0
  149. testgen/template/observability/get_test_results.sql +41 -0
  150. testgen/template/observability/update_test_results_exported_to_observability.sql +12 -0
  151. testgen/template/parms/parms_profiling.sql +34 -0
  152. testgen/template/parms/parms_test_execution.sql +13 -0
  153. testgen/template/parms/parms_test_gen.sql +23 -0
  154. testgen/template/profiling/contingency_columns.sql +7 -0
  155. testgen/template/profiling/datatype_suggestions.sql +56 -0
  156. testgen/template/profiling/functional_datatype.sql +523 -0
  157. testgen/template/profiling/functional_tabletype_stage.sql +48 -0
  158. testgen/template/profiling/functional_tabletype_update.sql +8 -0
  159. testgen/template/profiling/pii_flag.sql +133 -0
  160. testgen/template/profiling/profile_anomalies_screen_column.sql +22 -0
  161. testgen/template/profiling/profile_anomalies_screen_multi_column.sql +58 -0
  162. testgen/template/profiling/profile_anomalies_screen_table.sql +22 -0
  163. testgen/template/profiling/profile_anomalies_screen_table_dates.sql +30 -0
  164. testgen/template/profiling/profile_anomalies_screen_variants.sql +40 -0
  165. testgen/template/profiling/profile_anomaly_types_get.sql +3 -0
  166. testgen/template/profiling/project_get_table_sample_count.sql +22 -0
  167. testgen/template/profiling/project_profile_run_record_insert.sql +8 -0
  168. testgen/template/profiling/project_profile_run_record_update.sql +5 -0
  169. testgen/template/profiling/project_profile_run_record_update_status.sql +5 -0
  170. testgen/template/profiling/project_update_profile_results_to_estimates.sql +32 -0
  171. testgen/template/profiling/refresh_anomalies.sql +33 -0
  172. testgen/template/profiling/refresh_data_chars_from_profiling.sql +156 -0
  173. testgen/template/profiling/secondary_profiling_columns.sql +12 -0
  174. testgen/template/profiling/secondary_profiling_delete.sql +4 -0
  175. testgen/template/profiling/secondary_profiling_update.sql +18 -0
  176. testgen/template/quick_start/populate_target_data.sql +1077 -0
  177. testgen/template/quick_start/recreate_target_data_schema.sql +167 -0
  178. testgen/template/quick_start/update_target_data.sql +100 -0
  179. testgen/template/updates/create_tmp_test_definition.sql +19 -0
  180. testgen/template/updates/get_test_def_parms.sql +38 -0
  181. testgen/template/updates/populate_stg_test_definitions.sql +184 -0
  182. testgen/template/validate_tests/ex_disable_tests_test_definitions.sql +5 -0
  183. testgen/template/validate_tests/ex_flag_tests_test_definitions.sql +64 -0
  184. testgen/template/validate_tests/ex_get_project_column_list_generic.sql +3 -0
  185. testgen/template/validate_tests/ex_get_test_column_list_tg.sql +65 -0
  186. testgen/template/validate_tests/ex_write_test_val_errors.sql +22 -0
  187. testgen/ui/__init__.py +0 -0
  188. testgen/ui/app.py +98 -0
  189. testgen/ui/assets/dk_logo.svg +46 -0
  190. testgen/ui/assets/question_mark.png +0 -0
  191. testgen/ui/assets/scripts.js +68 -0
  192. testgen/ui/assets/style.css +140 -0
  193. testgen/ui/bootstrap.py +109 -0
  194. testgen/ui/components/__init__.py +0 -0
  195. testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 +0 -0
  196. testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 +0 -0
  197. testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu4mxK.woff2 +0 -0
  198. testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 +0 -0
  199. testgen/ui/components/frontend/css/material-symbols-rounded.css +24 -0
  200. testgen/ui/components/frontend/css/material-symbols-rounded.woff2 +0 -0
  201. testgen/ui/components/frontend/css/roboto-font-faces.css +35 -0
  202. testgen/ui/components/frontend/css/shared.css +36 -0
  203. testgen/ui/components/frontend/img/dk_logo.svg +46 -0
  204. testgen/ui/components/frontend/index.html +17 -0
  205. testgen/ui/components/frontend/js/components/breadcrumbs.js +86 -0
  206. testgen/ui/components/frontend/js/components/button.js +66 -0
  207. testgen/ui/components/frontend/js/components/location.js +62 -0
  208. testgen/ui/components/frontend/js/components/select.js +75 -0
  209. testgen/ui/components/frontend/js/components/sidebar.js +358 -0
  210. testgen/ui/components/frontend/js/main.js +99 -0
  211. testgen/ui/components/frontend/js/streamlit.js +19 -0
  212. testgen/ui/components/frontend/js/van.min.js +1 -0
  213. testgen/ui/components/utils/__init__.py +0 -0
  214. testgen/ui/components/utils/callbacks.py +51 -0
  215. testgen/ui/components/utils/component.py +13 -0
  216. testgen/ui/components/widgets/__init__.py +6 -0
  217. testgen/ui/components/widgets/breadcrumbs.py +32 -0
  218. testgen/ui/components/widgets/location.py +65 -0
  219. testgen/ui/components/widgets/modal.py +97 -0
  220. testgen/ui/components/widgets/sidebar.py +69 -0
  221. testgen/ui/navigation/__init__.py +0 -0
  222. testgen/ui/navigation/menu.py +42 -0
  223. testgen/ui/navigation/page.py +20 -0
  224. testgen/ui/navigation/router.py +63 -0
  225. testgen/ui/queries/__init__.py +0 -0
  226. testgen/ui/queries/authentication_queries.py +47 -0
  227. testgen/ui/queries/connection_queries.py +121 -0
  228. testgen/ui/queries/profiling_queries.py +148 -0
  229. testgen/ui/queries/project_queries.py +9 -0
  230. testgen/ui/queries/table_group_queries.py +186 -0
  231. testgen/ui/queries/test_definition_queries.py +270 -0
  232. testgen/ui/queries/test_run_queries.py +32 -0
  233. testgen/ui/queries/test_suite_queries.py +145 -0
  234. testgen/ui/scripts/__init__.py +0 -0
  235. testgen/ui/scripts/patch_streamlit.py +111 -0
  236. testgen/ui/services/__init__.py +0 -0
  237. testgen/ui/services/authentication_service.py +119 -0
  238. testgen/ui/services/connection_service.py +220 -0
  239. testgen/ui/services/database_service.py +282 -0
  240. testgen/ui/services/form_service.py +1008 -0
  241. testgen/ui/services/javascript_service.py +44 -0
  242. testgen/ui/services/query_service.py +316 -0
  243. testgen/ui/services/string_service.py +12 -0
  244. testgen/ui/services/table_group_service.py +130 -0
  245. testgen/ui/services/test_definition_service.py +117 -0
  246. testgen/ui/services/test_run_service.py +13 -0
  247. testgen/ui/services/test_suite_service.py +76 -0
  248. testgen/ui/services/toolbar_service.py +77 -0
  249. testgen/ui/session.py +46 -0
  250. testgen/ui/views/__init__.py +0 -0
  251. testgen/ui/views/app_log_modal.py +92 -0
  252. testgen/ui/views/connections.py +72 -0
  253. testgen/ui/views/connections_base.py +367 -0
  254. testgen/ui/views/login.py +40 -0
  255. testgen/ui/views/not_found.py +16 -0
  256. testgen/ui/views/overview.py +34 -0
  257. testgen/ui/views/profiling_anomalies.py +501 -0
  258. testgen/ui/views/profiling_details.py +335 -0
  259. testgen/ui/views/profiling_modal.py +40 -0
  260. testgen/ui/views/profiling_results.py +206 -0
  261. testgen/ui/views/profiling_summary.py +177 -0
  262. testgen/ui/views/project_settings.py +74 -0
  263. testgen/ui/views/table_groups.py +530 -0
  264. testgen/ui/views/test_definitions.py +1020 -0
  265. testgen/ui/views/test_results.py +908 -0
  266. testgen/ui/views/test_runs.py +195 -0
  267. testgen/ui/views/test_suites.py +545 -0
  268. testgen/utils/__init__.py +0 -0
  269. testgen/utils/plugins.py +17 -0
  270. testgen/utils/singleton.py +14 -0
@@ -0,0 +1,248 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ -- ==============================================================================
4
+ -- | Creates Standard Views:
5
+ -- | Runs on new or existing schema, so DROP VIEWS IF EXIST first
6
+ -- ==============================================================================
7
+
8
+ DROP VIEW IF EXISTS v_latest_profile_results CASCADE;
9
+
10
+ CREATE VIEW v_latest_profile_results
11
+ AS
12
+ WITH last_run AS ( SELECT table_groups_id,
13
+ MAX(profiling_starttime) AS last_run_date
14
+ FROM profiling_runs
15
+ GROUP BY table_groups_id )
16
+ SELECT r.*
17
+ FROM last_run lr
18
+ INNER JOIN profiling_runs p
19
+ ON lr.table_groups_id = p.table_groups_id
20
+ AND lr.last_run_date = p.profiling_starttime
21
+ INNER JOIN profile_results r
22
+ ON p.id = r.profile_run_id;
23
+
24
+
25
+ DROP VIEW IF EXISTS v_latest_profile_anomalies;
26
+
27
+ CREATE VIEW v_latest_profile_anomalies
28
+ AS
29
+ WITH last_profile_date
30
+ AS (SELECT table_groups_id, MAX(profiling_starttime) as last_profile_run_date
31
+ FROM profiling_runs
32
+ GROUP BY table_groups_id)
33
+ SELECT r.id, r.project_code, r.table_groups_id,
34
+ r.profile_run_id, pr.profiling_starttime as profile_run_date,
35
+ r.schema_name, r.table_name, r.column_name, r.column_type,
36
+ t.anomaly_name, t.anomaly_description, t.issue_likelihood,
37
+ r.detail,
38
+ t.suggested_action, r.disposition
39
+ FROM profile_anomaly_results r
40
+ INNER JOIN profile_anomaly_types t
41
+ ON r.anomaly_id = t.id
42
+ INNER JOIN profiling_runs pr
43
+ ON (r.profile_run_id = pr.id)
44
+ INNER JOIN last_profile_date l
45
+ ON (pr.table_groups_id = l.table_groups_id
46
+ AND pr.profiling_starttime = l.last_profile_run_date);
47
+
48
+
49
+ DROP VIEW IF EXISTS v_inactive_anomalies;
50
+
51
+ CREATE VIEW v_inactive_anomalies
52
+ AS
53
+ SELECT DISTINCT anomaly_id, table_groups_id, schema_name, table_name, column_name, column_id
54
+ FROM profile_anomaly_results
55
+ WHERE disposition = 'Inactive';
56
+
57
+
58
+ DROP VIEW IF EXISTS v_profiling_runs;
59
+
60
+ CREATE VIEW v_profiling_runs
61
+ AS
62
+ SELECT r.id as profiling_run_id,
63
+ r.project_code, cc.connection_name, r.connection_id, r.table_groups_id,
64
+ tg.table_groups_name,
65
+ tg.table_group_schema as schema_name,
66
+ r.profiling_starttime as start_time,
67
+ TO_CHAR(r.profiling_endtime - r.profiling_starttime, 'HH24:MI:SS') as duration,
68
+ r.status,
69
+ r.log_message,
70
+ r.table_ct,
71
+ r.column_ct,
72
+ r.anomaly_ct, r.anomaly_table_ct, r.anomaly_column_ct, process_id
73
+ FROM profiling_runs r
74
+ INNER JOIN table_groups tg
75
+ ON r.table_groups_id = tg.id
76
+ INNER JOIN connections cc
77
+ ON r.connection_id = cc.connection_id
78
+ GROUP BY r.id, r.project_code, cc.connection_name, r.connection_id,
79
+ r.table_groups_id, tg.table_groups_name, tg.table_group_schema,
80
+ r.profiling_starttime, r.profiling_endtime, r.status;
81
+
82
+
83
+ DROP VIEW IF EXISTS v_test_runs;
84
+
85
+ CREATE VIEW v_test_runs
86
+ AS
87
+ SELECT r.id as test_run_id,
88
+ r.project_code, p.project_name,
89
+ r.test_suite,
90
+ r.test_starttime,
91
+ TO_CHAR(r.test_endtime - r.test_starttime, 'HH24:MI:SS') as duration,
92
+ r.status, r.log_message,
93
+ COUNT(*) as test_ct,
94
+ SUM(result_code) as passed_ct,
95
+ COALESCE(SUM(CASE WHEN tr.result_status = 'Failed' THEN 1 END), 0) as failed_ct,
96
+ COALESCE(SUM(CASE WHEN tr.result_status = 'Warning' THEN 1 END), 0) as warning_ct,
97
+ r.process_id
98
+ FROM test_runs r
99
+ INNER JOIN projects p
100
+ ON (r.project_code = p.project_code)
101
+ INNER JOIN test_results tr
102
+ ON (r.id = tr.test_run_id)
103
+ GROUP BY r.id, r.project_code, r.test_suite, r.test_starttime, r.test_endtime,
104
+ r.process_id, r.status, r.log_message, p.project_name;
105
+
106
+
107
+ DROP VIEW IF EXISTS v_test_results;
108
+
109
+ CREATE VIEW v_test_results
110
+ AS
111
+ SELECT p.project_name,
112
+ ts.test_suite,
113
+ tg.table_groups_name,
114
+ cn.connection_name, cn.project_host, cn.sql_flavor,
115
+ tt.dq_dimension,
116
+ r.schema_name, r.table_name, r.column_names,
117
+ r.test_time as test_date,
118
+ r.test_type, tt.id as test_type_id, tt.test_name_short, tt.test_name_long,
119
+ r.test_description,
120
+ tt.measure_uom, tt.measure_uom_description,
121
+ c.test_operator,
122
+ r.threshold_value::NUMERIC(16, 5) as threshold_value,
123
+ r.result_measure::NUMERIC(16, 5),
124
+ r.result_status,
125
+ r.input_parameters,
126
+ r.result_message,
127
+ CASE WHEN result_code <> 1 THEN r.severity END as severity,
128
+ CASE
129
+ WHEN result_code <> 1 THEN r.disposition
130
+ ELSE 'Passed'
131
+ END as disposition,
132
+ r.result_code as passed_ct,
133
+ (1 - r.result_code)::INTEGER as exception_ct,
134
+ CASE
135
+ WHEN result_status = 'Warning'
136
+ AND result_message NOT ILIKE 'ERROR - TEST COLUMN MISSING%' THEN 1
137
+ END::INTEGER as warning_ct,
138
+ CASE
139
+ WHEN result_status = 'Failed'
140
+ AND result_message NOT ILIKE 'ERROR - TEST COLUMN MISSING%' THEN 1
141
+ END::INTEGER as failed_ct,
142
+ CASE
143
+ WHEN result_message ILIKE 'ERROR - TEST COLUMN MISSING%' THEN 1
144
+ END as execution_error_ct,
145
+ r.project_code,
146
+ r.table_groups_id,
147
+ r.id as test_result_id, c.id as connection_id,
148
+ r.test_suite_id,
149
+ r.test_definition_id as test_definition_id_runtime,
150
+ CASE
151
+ WHEN r.auto_gen = TRUE THEN d.id
152
+ ELSE r.test_definition_id
153
+ END as test_definition_id_current,
154
+ r.test_run_id as test_run_id,
155
+ r.auto_gen
156
+ FROM test_results r
157
+ INNER JOIN test_types tt
158
+ ON (r.test_type = tt.test_type)
159
+ LEFT JOIN test_definitions d
160
+ ON (r.test_suite_id = d.test_suite_id
161
+ AND r.table_name = d.table_name
162
+ AND r.column_names = COALESCE(d.column_name, 'N/A')
163
+ AND r.test_type = d.test_type
164
+ AND r.auto_gen = TRUE
165
+ AND d.last_auto_gen_date IS NOT NULL)
166
+ INNER JOIN test_suites ts
167
+ ON (r.test_suite_id = ts.id)
168
+ INNER JOIN projects p
169
+ ON (r.project_code = p.project_code)
170
+ INNER JOIN table_groups tg
171
+ ON (r.table_groups_id = tg.id)
172
+ INNER JOIN connections cn
173
+ ON (tg.connection_id = cn.connection_id)
174
+ LEFT JOIN cat_test_conditions c
175
+ ON (cn.sql_flavor = c.sql_flavor
176
+ AND r.test_type = c.test_type);
177
+
178
+
179
+ DROP VIEW IF EXISTS v_queued_observability_results;
180
+
181
+ CREATE VIEW v_queued_observability_results
182
+ AS
183
+ SELECT
184
+ p.project_name,
185
+ cn.sql_flavor as component_tool,
186
+ ts.test_suite_schema as schema,
187
+ cn.connection_name,
188
+ cn.project_db,
189
+
190
+ CASE
191
+ WHEN tg.profile_use_sampling = 'Y' THEN tg.profile_sample_min_count
192
+ END as sample_min_count,
193
+ tg.id as group_id,
194
+ tg.profile_use_sampling = 'Y' as uses_sampling,
195
+ r.project_code,
196
+ CASE
197
+ WHEN tg.profile_use_sampling = 'Y' THEN tg.profile_sample_percent
198
+ END as sample_percentage,
199
+
200
+ tg.profiling_table_set,
201
+ tg.profiling_include_mask,
202
+ tg.profiling_exclude_mask,
203
+
204
+ COALESCE(ts.component_type, 'dataset') as component_type,
205
+ COALESCE(ts.component_key, tg.id::VARCHAR) as component_key,
206
+ COALESCE(ts.component_name, tg.table_groups_name) as component_name,
207
+
208
+ r.column_names,
209
+ r.table_name,
210
+ r.test_suite,
211
+ r.input_parameters,
212
+ r.test_definition_id,
213
+ tt.test_name_short as type,
214
+ CASE
215
+ WHEN c.test_operator IN ('>', '>=') THEN d.threshold_value
216
+ END as min_threshold,
217
+ CASE
218
+ WHEN c.test_operator IN ('<', '<=') THEN d.threshold_value
219
+ END as max_threshold,
220
+ tt.test_name_long as name,
221
+ tt.test_description as description,
222
+ r.test_time as start_time,
223
+ r.test_time as end_time,
224
+ r.result_message as result_message,
225
+ tt.dq_dimension,
226
+ r.result_status,
227
+ r.result_id,
228
+ r.result_measure as metric_value,
229
+ tt.measure_uom,
230
+ tt.measure_uom_description
231
+ FROM test_results r
232
+ INNER JOIN test_types tt
233
+ ON (r.test_type = tt.test_type)
234
+ INNER JOIN test_definitions d
235
+ ON (r.test_definition_id = d.id)
236
+ INNER JOIN test_suites ts
237
+ ON (r.project_code = ts.project_code
238
+ AND r.test_suite = ts.test_suite)
239
+ INNER JOIN table_groups tg
240
+ ON (d.table_groups_id = tg.id)
241
+ INNER JOIN connections cn
242
+ ON (tg.connection_id = cn.connection_id)
243
+ INNER JOIN projects p
244
+ ON (r.project_code = p.project_code)
245
+ INNER JOIN cat_test_conditions c
246
+ ON (cn.sql_flavor = c.sql_flavor
247
+ AND d.test_type = c.test_type)
248
+ WHERE r.observability_status = 'Queued';
@@ -0,0 +1,17 @@
1
+ -- ==============================================================================
2
+ -- | Create default roles and users if not present |
3
+ -- ==============================================================================
4
+
5
+ -- testgen_execute_role: read-write to operational tables, otherwise read-only
6
+ CREATE ROLE testgen_execute_role;
7
+
8
+ --create user and assign role
9
+ CREATE USER {TESTGEN_USER} WITH PASSWORD '{TESTGEN_PASSWORD}';
10
+ GRANT testgen_execute_role TO {TESTGEN_USER};
11
+
12
+ -- testgen_report_role: Read-Only to all data
13
+ CREATE ROLE testgen_report_role;
14
+
15
+ --create user and assign role
16
+ CREATE USER {TESTGEN_REPORT_USER} WITH PASSWORD '{TESTGEN_REPORT_PASSWORD}';
17
+ GRANT testgen_report_role TO {TESTGEN_REPORT_USER};
@@ -0,0 +1,43 @@
1
+ -- ==============================================================================
2
+ -- | Assigns Standard Rights to Roles:
3
+ -- | Runs on schema create or upgrade.
4
+ -- | No new objects should be created in this script.
5
+ -- ==============================================================================
6
+
7
+ -- testgen_execute_role:
8
+ -- read-write to test_results, test_suites, test_definitions
9
+ -- read-only to all other tables
10
+ GRANT USAGE ON SCHEMA {SCHEMA_NAME} TO testgen_execute_role;
11
+ GRANT SELECT ON ALL TABLES IN SCHEMA {SCHEMA_NAME} TO testgen_execute_role;
12
+ GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA {SCHEMA_NAME} TO testgen_execute_role;
13
+ GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA {SCHEMA_NAME} TO testgen_execute_role;
14
+ GRANT SELECT, INSERT, DELETE, UPDATE ON
15
+ {SCHEMA_NAME}.test_results,
16
+ {SCHEMA_NAME}.test_suites,
17
+ {SCHEMA_NAME}.test_definitions,
18
+ {SCHEMA_NAME}.profiling_runs,
19
+ {SCHEMA_NAME}.profile_results,
20
+ {SCHEMA_NAME}.profile_pair_rules,
21
+ {SCHEMA_NAME}.profile_anomaly_results,
22
+ {SCHEMA_NAME}.stg_functional_table_updates,
23
+ {SCHEMA_NAME}.stg_secondary_profile_updates,
24
+ {SCHEMA_NAME}.test_runs,
25
+ {SCHEMA_NAME}.working_agg_cat_results,
26
+ {SCHEMA_NAME}.working_agg_cat_tests,
27
+ {SCHEMA_NAME}.functional_test_results,
28
+ {SCHEMA_NAME}.connections,
29
+ {SCHEMA_NAME}.table_groups,
30
+ {SCHEMA_NAME}.projects,
31
+ {SCHEMA_NAME}.data_table_chars,
32
+ {SCHEMA_NAME}.data_column_chars,
33
+ {SCHEMA_NAME}.auth_users
34
+ TO testgen_execute_role;
35
+
36
+
37
+
38
+ -- testgen_report_role:
39
+ -- read-only to all data
40
+ GRANT USAGE ON SCHEMA {SCHEMA_NAME} TO testgen_report_role;
41
+ GRANT SELECT ON ALL TABLES IN SCHEMA {SCHEMA_NAME} TO testgen_report_role;
42
+ GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA {SCHEMA_NAME} TO testgen_report_role;
43
+ GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA {SCHEMA_NAME} TO testgen_report_role;
@@ -0,0 +1,5 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ UPDATE tg_revision
4
+ SET revision = {DB_REVISION}
5
+ WHERE component = 'metadata_db';
@@ -0,0 +1,5 @@
1
+ -- ===========================================
2
+ -- | Initial App DB Schema Upgrade |
3
+ -- ===========================================
4
+
5
+ SELECT 1;
@@ -0,0 +1,15 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ DO $$
4
+ BEGIN
5
+ IF NOT EXISTS (
6
+ SELECT 1
7
+ FROM information_schema.columns
8
+ where table_schema = '{SCHEMA_NAME}'
9
+ and table_name='projects'
10
+ AND column_name='observability_api_url'
11
+ ) THEN
12
+ alter table {SCHEMA_NAME}.projects add column observability_api_url TEXT DEFAULT '';
13
+ update {SCHEMA_NAME}.projects set observability_api_url='{OBSERVABILITY_URL}' WHERE observability_api_url = '';
14
+ END IF;
15
+ END $$;
@@ -0,0 +1,4 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ alter table {SCHEMA_NAME}.profiling_runs add column process_id INTEGER;
4
+ alter table {SCHEMA_NAME}.test_runs add column process_id INTEGER;
@@ -0,0 +1,22 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ ALTER TABLE test_types
4
+ ADD COLUMN column_name_prompt TEXT;
5
+
6
+ ALTER TABLE test_types
7
+ ADD COLUMN column_name_help TEXT;
8
+
9
+ ALTER TABLE test_results
10
+ ADD COLUMN auto_gen BOOLEAN;
11
+
12
+ UPDATE test_results
13
+ SET auto_gen = TRUE
14
+ FROM test_results r
15
+ INNER JOIN test_definitions d
16
+ ON (r.project_code = d.project_code
17
+ AND r.test_suite = d.test_suite
18
+ AND r.table_name = d.table_name
19
+ AND r.column_names = COALESCE(d.column_name, 'N/A')
20
+ AND r.test_type = d.test_type)
21
+ WHERE d.last_auto_gen_date IS NOT NULL
22
+ AND test_results.id = r.id;
@@ -0,0 +1,44 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ ALTER TABLE test_results
4
+ ADD COLUMN test_suite_id UUID;
5
+
6
+ UPDATE test_results
7
+ SET test_suite_id = s.id
8
+ FROM test_results r
9
+ INNER JOIN test_suites s
10
+ ON (r.table_groups_id = s.table_groups_id
11
+ AND r.test_suite = s.test_suite)
12
+ WHERE test_results.id = r.id;
13
+
14
+ CREATE INDEX ix_tr_ts_tctt
15
+ ON test_results(test_suite_id, table_name, column_names, test_type);
16
+
17
+ ALTER TABLE test_definitions
18
+ ADD COLUMN test_suite_id UUID;
19
+
20
+ UPDATE test_definitions
21
+ SET test_suite_id = s.id
22
+ FROM test_definitions d
23
+ INNER JOIN test_suites s
24
+ ON (D.table_groups_id = s.table_groups_id
25
+ AND d.test_suite = s.test_suite)
26
+ WHERE test_definitions.id = d.id;
27
+
28
+ CREATE INDEX ix_td_ts_tc
29
+ ON test_definitions(test_suite_id, table_name, column_name, test_type);
30
+
31
+ ALTER TABLE table_groups
32
+ ADD COLUMN data_source VARCHAR(40),
33
+ ADD COLUMN source_system VARCHAR(40),
34
+ ADD COLUMN data_location VARCHAR(40),
35
+ ADD COLUMN source_process VARCHAR(40),
36
+ ADD COLUMN business_domain VARCHAR(40),
37
+ ADD COLUMN stakeholder_group VARCHAR(40),
38
+ ADD COLUMN transform_level VARCHAR(40);
39
+
40
+ ALTER TABLE data_table_chars
41
+ RENAME COLUMN transformation_level to transform_level;
42
+
43
+ ALTER TABLE data_column_chars
44
+ RENAME COLUMN transformation_level to transform_level;
@@ -0,0 +1 @@
1
+ SELECT 1;
@@ -0,0 +1,5 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ ALTER TABLE connections ADD COLUMN connect_by_key BOOLEAN DEFAULT FALSE;
4
+ ALTER TABLE connections ADD COLUMN private_key BYTEA;
5
+ ALTER TABLE connections ADD COLUMN private_key_passphrase BYTEA;
@@ -0,0 +1,3 @@
1
+ SET SEARCH_PATH TO {SCHEMA_NAME};
2
+
3
+ ALTER TABLE profile_results ADD COLUMN pii_flag VARCHAR(50);
@@ -0,0 +1,2 @@
1
+ SELECT revision
2
+ FROM {SCHEMA_NAME}.tg_revision;
@@ -0,0 +1,116 @@
1
+ -- Create one record per CAT query: all test sets against one table, split over max chars
2
+ INSERT INTO working_agg_cat_tests
3
+ (project_code, test_run_id,
4
+ test_suite, schema_name, table_name, cat_sequence, test_count, test_time,
5
+ column_names, test_types, test_definition_ids,
6
+ test_actions, test_descriptions,
7
+ test_parms, test_measures, test_conditions)
8
+ -- Test details from each test type
9
+ WITH test_detail
10
+ AS (
11
+ SELECT '{TEST_SUITE}' as test_suite,
12
+ '{SCHEMA_NAME}' as schema_name, '{TABLE_NAME}' as table_name,
13
+ '{RUN_DATE}'::TIMESTAMP as test_time,
14
+ t.column_name, t.test_type, t.id::VARCHAR as test_definition_id,
15
+ t.test_action, t.test_description,
16
+
17
+ SUBSTRING(
18
+ CASE WHEN t.baseline_ct > '' THEN ', Baseline_Ct=' || t.baseline_ct ELSE '' END
19
+ || CASE WHEN t.baseline_unique_ct > '' THEN ', Baseline_Unique_Ct=' || t.baseline_unique_ct ELSE '' END
20
+ || CASE WHEN t.baseline_value > '' THEN ', Baseline_Value=' || t.baseline_value ELSE '' END
21
+ || CASE WHEN t.baseline_value_ct > '' THEN ', Baseline_Value_Ct=' || t.baseline_value_ct ELSE '' END
22
+ || CASE WHEN t.baseline_sum > '' THEN ', Baseline_Sum=' || t.baseline_sum ELSE '' END
23
+ || CASE WHEN t.baseline_avg > '' THEN ', Baseline_Avg=' || t.baseline_avg ELSE '' END
24
+ || CASE WHEN t.baseline_sd > '' THEN ', Baseline_SD=' || t.baseline_sd ELSE '' END
25
+ || CASE WHEN t.threshold_value > '' THEN ', Threshold_Value=' || t.threshold_value ELSE '' END,
26
+ 3, 999) || ' '
27
+ as parms,
28
+
29
+ -- Standard Measure start
30
+ 'CAST(' ||
31
+ -- Nested parm replacements - part of query, not Python parms
32
+ REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
33
+ c.measure,
34
+ '{COLUMN_NAME}', COALESCE(fn_PrepColumnName(t.column_name), '')),
35
+ '{DATA_QC_SCHEMA}', '{REPLACE_QC_SCHEMA}'),
36
+ '{BASELINE_CT}', COALESCE(t.baseline_ct, '')),
37
+ '{BASELINE_UNIQUE_CT}', COALESCE(t.baseline_unique_ct, '')),
38
+ '{BASELINE_VALUE}', COALESCE(t.baseline_value, '') ),
39
+ '{BASELINE_VALUE_CT}', COALESCE(t.baseline_value_ct, '') ),
40
+ '{BASELINE_SUM}', COALESCE(t.baseline_sum, '') ),
41
+ '{BASELINE_AVG}', COALESCE(t.baseline_avg, '') ),
42
+ '{BASELINE_SD}', COALESCE(t.baseline_sd, '') ),
43
+ '{CUSTOM_QUERY}', COALESCE(t.custom_query, '')),
44
+ '{THRESHOLD_VALUE}', COALESCE(t.threshold_value, '') )
45
+ -- Standard measure end with pipe delimiter
46
+ || ' AS VARCHAR(1000) ) {CONCAT_OPERATOR} ''|'' ' as measure,
47
+
48
+ -- Standard CASE for condition starts
49
+ 'CASE WHEN ' ||
50
+ -- Nested parm replacements - standard
51
+ REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
52
+ c.measure || c.test_operator || c.test_condition,
53
+ '{COLUMN_NAME}', COALESCE(fn_PrepColumnName(t.column_name), '')),
54
+ '{DATA_QC_SCHEMA}', '{REPLACE_QC_SCHEMA}'),
55
+ '{BASELINE_CT}', COALESCE(t.baseline_ct, '')),
56
+ '{BASELINE_UNIQUE_CT}', COALESCE(t.baseline_unique_ct, '')),
57
+ '{BASELINE_VALUE}', COALESCE(t.baseline_value, '') ),
58
+ '{BASELINE_VALUE_CT}', COALESCE(t.baseline_value_ct, '') ),
59
+ '{BASELINE_SUM}', COALESCE(t.baseline_sum, '') ),
60
+ '{BASELINE_AVG}', COALESCE(t.baseline_avg, '') ),
61
+ '{BASELINE_SD}', COALESCE(t.baseline_sd, '') ),
62
+ '{CUSTOM_QUERY}', COALESCE(t.custom_query, '')),
63
+ '{THRESHOLD_VALUE}', COALESCE(t.threshold_value, '') )
64
+ -- Standard case ends
65
+ || ' THEN ''0,'' ELSE ''1,'' END' as condition
66
+ FROM test_definitions t
67
+ INNER JOIN cat_test_conditions c
68
+ ON (t.test_type = c.test_type
69
+ AND '{SQL_FLAVOR}' = c.sql_flavor)
70
+ WHERE t.project_code = '{PROJECT_CODE}'
71
+ AND t.test_suite = '{TEST_SUITE}'
72
+ AND t.schema_name = '{SCHEMA_NAME}'
73
+ AND t.table_name = '{TABLE_NAME}'
74
+ AND COALESCE(t.test_active, 'Y') = 'Y'
75
+ ),
76
+ test_detail_split
77
+ AS ( SELECT test_suite, schema_name, table_name, test_time,
78
+ column_name, test_type, test_definition_id, test_action, test_description,
79
+ parms, measure, condition,
80
+ SUM(LENGTH(condition)) OVER (PARTITION BY t.schema_name, t.table_name
81
+ ORDER BY t.column_name ROWS UNBOUNDED PRECEDING ) as run_total_chars,
82
+ FLOOR( SUM(LENGTH(condition)) OVER (PARTITION BY t.schema_name, t.table_name
83
+ ORDER BY t.column_name ROWS UNBOUNDED PRECEDING )
84
+ / {MAX_QUERY_CHARS} ) + 1 as query_split_no
85
+ FROM test_detail t )
86
+ SELECT
87
+ '{PROJECT_CODE}' as project_code,
88
+ '{TEST_RUN_ID}' as test_run_id,
89
+ d.test_suite,
90
+ d.schema_name, d.table_name,
91
+ d.query_split_no as cat_sequence,
92
+ COUNT(*) as test_count,
93
+ '{RUN_DATE}'::TIMESTAMP as test_time,
94
+ STRING_AGG(COALESCE(d.column_name, 'N/A'), '~|~' ORDER BY d.column_name) as column_names,
95
+ STRING_AGG(d.test_type, ',' ORDER BY d.column_name) as test_types,
96
+ STRING_AGG(d.test_definition_id, ',' ORDER BY d.column_name) as test_definition_ids,
97
+ -- Pipe delimiter below, because commas may be embedded
98
+ STRING_AGG(d.test_action, '|' ORDER BY d.column_name) as test_actions,
99
+ STRING_AGG(d.test_description, '|' ORDER BY d.column_name) as test_descriptions,
100
+
101
+ -- Consolidated Parms
102
+ STRING_AGG( d.parms, '|' ORDER BY d.column_name) as parms,
103
+
104
+ -- Consolidated Measures
105
+ -- Encode Null as text to decode when freeing kittens
106
+ STRING_AGG( 'COALESCE(' || d.measure || ',''' || '<NULL>' || '|'')',
107
+ -- Use ++ as STRING_AGG delimiter -- replace with + later
108
+ '++' ORDER BY d.column_name) as measures,
109
+
110
+ -- Consolidated CASE statements
111
+ STRING_AGG( d.condition,
112
+ -- Use ++ as STRING_AGG delimiter -- replace with + later
113
+ '++' ORDER BY d.column_name) as conditions
114
+
115
+ FROM test_detail_split d
116
+ GROUP BY d.test_suite, d.schema_name, d.table_name, test_time, d.query_split_no;
@@ -0,0 +1,11 @@
1
+ SELECT DISTINCT schema_name, table_name,
2
+ project_qc_schema as replace_qc_schema
3
+ FROM test_definitions t
4
+ INNER JOIN test_types tt
5
+ ON t.test_type = tt.test_type
6
+ INNER JOIN table_groups tg
7
+ ON (t.table_groups_id = tg.id)
8
+ INNER JOIN connections c
9
+ ON (tg.connection_id = c.connection_id)
10
+ WHERE t.test_suite = '{TEST_SUITE}'
11
+ AND tt.run_type = 'CAT';
@@ -0,0 +1,69 @@
1
+ -- Parses aggregated results and inserts into test_results table
2
+ WITH seq_digit AS (
3
+ SELECT 0 as d UNION ALL
4
+ SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
5
+ SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
6
+ SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 ),
7
+ seq_table_raw AS (
8
+ SELECT CAST(a.d + (10 * b.d) + (100 * c.d) + (1000 * d.d) as INT) as nbr
9
+ FROM seq_digit a CROSS JOIN seq_digit b CROSS JOIN seq_digit c CROSS JOIN seq_digit d
10
+ ORDER BY nbr LIMIT 1000),
11
+ seq_table AS (
12
+ SELECT nbr FROM seq_table_raw WHERE nbr > 0),
13
+ raw_results AS (
14
+ SELECT t.project_code, t.test_run_id, t.test_suite, t.schema_name, t.table_name, t.cat_sequence, t.test_count,
15
+ t.test_time, t.start_time, t.end_time, t.column_names, t.test_types, t.test_definition_ids,
16
+ t.test_actions, t.test_descriptions,
17
+ t.test_parms, t.test_measures, t.test_conditions,
18
+ r.measure_results, r.test_results
19
+ FROM working_agg_cat_tests t
20
+ INNER JOIN working_agg_cat_results r
21
+ ON (t.test_run_id = r.test_run_id
22
+ AND t.schema_name = r.schema_name
23
+ AND t.table_name = r.table_name
24
+ AND t.cat_sequence = r.cat_sequence)
25
+ WHERE t.test_run_id = '{TEST_RUN_ID}'
26
+ AND t.column_names > ''
27
+ ),
28
+ parsed_results AS (
29
+ SELECT t.test_suite,
30
+ t.schema_name,
31
+ t.table_name,
32
+ t.test_time,
33
+ t.start_time,
34
+ t.end_time,
35
+ nbr AS test_number,
36
+ SPLIT_PART(t.test_actions, '|,', s.nbr) AS test_action,
37
+ SPLIT_PART(t.test_descriptions, '|', s.nbr) AS test_description,
38
+ SPLIT_PART(t.column_names, '~|~', s.nbr) AS column_name,
39
+ SPLIT_PART(t.test_types, ',', s.nbr) AS test_type,
40
+ SPLIT_PART(t.test_definition_ids, ',', s.nbr) AS test_definition_id,
41
+ SPLIT_PART(t.test_parms, '|', s.nbr) AS test_parms,
42
+ SPLIT_PART(t.test_measures, '++', s.nbr) AS measure,
43
+ TRIM(SPLIT_PART(t.test_conditions, '++', s.nbr)) AS condition,
44
+ -- Restore encoded null value
45
+ NULLIF(SPLIT_PART(t.measure_results, '|', s.nbr), '<NULL>') AS measure_result,
46
+ SPLIT_PART(t.test_results, ',', s.nbr) AS test_result
47
+ FROM raw_results t
48
+ CROSS JOIN seq_table s
49
+ )
50
+ INSERT INTO test_results
51
+ (project_code, test_run_id,
52
+ test_type, test_definition_id,
53
+ test_suite, test_time, starttime, endtime, schema_name, table_name, column_names,
54
+ skip_errors, input_parameters, result_code,
55
+ result_measure, test_action, subset_condition, result_query, test_description)
56
+ SELECT '{PROJECT_CODE}' as project_code, '{TEST_RUN_ID}' as test_run_id,
57
+ r.test_type, r.test_definition_id::UUID, r.test_suite, r.test_time, r.start_time, r.end_time,
58
+ r.schema_name, r.table_name, r.column_name,
59
+ 0 as skip_errors,
60
+ r.test_parms as input_parameters,
61
+ r.test_result::INT as result_code,
62
+ r.measure_result as result_measure,
63
+ r.test_action, NULL as subset_condition,
64
+ 'SELECT ' || LEFT(REPLACE(r.condition, '{RUN_' || 'DATE}', '{RUN_DATE}'), LENGTH(REPLACE(r.condition, '{RUN_' || 'DATE}', '{RUN_DATE}')) - LENGTH(' THEN ''0,'' ELSE ''1,'' END')) || ' THEN 0 ELSE 1 END'
65
+ || ' FROM ' || r.schema_name || '.' || r.table_name as result_query,
66
+ COALESCE(r.test_description, c.test_description) as test_description
67
+ FROM parsed_results r
68
+ INNER JOIN test_types c
69
+ ON r.test_type = c.test_type;
@@ -0,0 +1,6 @@
1
+ SELECT test_suite, schema_name, table_name, cat_sequence,
2
+ -- Replace list delimiters with concat operator
3
+ REPLACE(test_measures, '++', '{CONCAT_OPERATOR}') as test_measures,
4
+ REPLACE(test_conditions, '++', '{CONCAT_OPERATOR}') as test_conditions
5
+ FROM working_agg_cat_tests
6
+ WHERE test_run_id = '{TEST_RUN_ID}';
@@ -0,0 +1,8 @@
1
+ SELECT '{TEST_RUN_ID}' as test_run_id,
2
+ '{TEST_SUITE}' as test_suite,
3
+ '{SCHEMA_NAME}' as schema_name,
4
+ '{TABLE_NAME}' as table_name,
5
+ '{CAT_SEQUENCE}' as cat_sequence,
6
+ {TEST_MEASURES} as measure_results,
7
+ {TEST_CONDITIONS} as test_results
8
+ FROM {SCHEMA_NAME}.{TABLE_NAME}