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,167 @@
1
+ create schema if not exists {PROJECT_SCHEMA};
2
+
3
+ SET SEARCH_PATH TO {PROJECT_SCHEMA};
4
+
5
+ DROP TABLE if exists d_ebike_customers CASCADE;
6
+
7
+ CREATE TABLE d_ebike_customers (
8
+ customer_id INTEGER,
9
+ first_name VARCHAR(50) NOT NULL,
10
+ last_name VARCHAR(50) NOT NULL,
11
+ address VARCHAR(255) NOT NULL,
12
+ city VARCHAR(100),
13
+ state VARCHAR(50),
14
+ postal_code VARCHAR(10),
15
+ country VARCHAR(100),
16
+ customer_type VARCHAR(20),
17
+ avg_age INT,
18
+ income_level VARCHAR(10),
19
+ gender VARCHAR(10),
20
+ occupation VARCHAR(100),
21
+ marital_status VARCHAR(20),
22
+ customer_note TEXT,
23
+ sales_region VARCHAR(10),
24
+ sales_territory VARCHAR(10),
25
+ customer_decile INT,
26
+ phone_number VARCHAR(40),
27
+ tax_id VARCHAR(15),
28
+ credit_card VARCHAR(20),
29
+ last_contact DATE
30
+ );
31
+
32
+ DROP TABLE if exists tmp_d_ebike_customers CASCADE;
33
+
34
+ CREATE TABLE tmp_d_ebike_customers (
35
+ customer_id INTEGER,
36
+ first_name VARCHAR(50) NOT NULL,
37
+ last_name VARCHAR(50) NOT NULL,
38
+ address VARCHAR(255) NOT NULL,
39
+ city VARCHAR(100),
40
+ state VARCHAR(50),
41
+ postal_code VARCHAR(10),
42
+ country VARCHAR(100),
43
+ customer_type VARCHAR(20),
44
+ avg_age INT,
45
+ income_level VARCHAR(10),
46
+ gender VARCHAR(10),
47
+ occupation VARCHAR(100),
48
+ marital_status VARCHAR(20),
49
+ customer_note TEXT,
50
+ sales_region VARCHAR(10),
51
+ sales_territory VARCHAR(10),
52
+ customer_decile INT,
53
+ phone_number VARCHAR(40),
54
+ tax_id VARCHAR(15),
55
+ credit_card VARCHAR(20),
56
+ last_contact DATE
57
+ );
58
+
59
+ DROP TABLE if exists d_ebike_products CASCADE;
60
+
61
+ CREATE TABLE d_ebike_products (
62
+ product_id INTEGER,
63
+ product_name VARCHAR(255) NOT NULL,
64
+ product_description TEXT,
65
+ product_type VARCHAR(50), --CHECK (product_type IN ('Bicycle', 'E-bike', 'E-scooter')),
66
+ frame_size VARCHAR(50),
67
+ battery_life INT, -- in hours; NULL for regular bicycles
68
+ max_speed DECIMAL(5,2), -- in mph or km/h; NULL for regular bicycles
69
+ weight_capacity DECIMAL(10,2), -- in lbs or kg
70
+ color VARCHAR(50),
71
+ wheel_size DECIMAL(5,2), -- in inches or cm
72
+ gear_count INT,
73
+ country_of_origin VARCHAR(50),
74
+ price DECIMAL(10,2) NOT NULL,
75
+ max_discount DECIMAL(5,2)
76
+ );
77
+
78
+ DROP TABLE if exists tmp_d_ebike_products CASCADE;
79
+
80
+ CREATE TABLE tmp_d_ebike_products (
81
+ product_id INTEGER,
82
+ product_name VARCHAR(255) NOT NULL,
83
+ product_description TEXT,
84
+ product_type VARCHAR(50), -- CHECK (product_type IN ('Bicycle', 'E-bike', 'E-scooter')),
85
+ frame_size VARCHAR(50),
86
+ battery_life INT, -- in hours; NULL for regular bicycles
87
+ max_speed DECIMAL(5,2), -- in mph or km/h; NULL for regular bicycles
88
+ weight_capacity DECIMAL(10,2), -- in lbs or kg
89
+ color VARCHAR(50),
90
+ wheel_size DECIMAL(5,2), -- in inches or cm
91
+ gear_count INT,
92
+ country_of_origin VARCHAR(50),
93
+ price DECIMAL(10,2) NOT NULL,
94
+ max_discount DECIMAL(5,2)
95
+ );
96
+
97
+ DROP TABLE IF EXISTS d_ebike_suppliers CASCADE;
98
+
99
+ CREATE TABLE d_ebike_suppliers (
100
+ supplier_id INTEGER,
101
+ supplier_name VARCHAR(255) NOT NULL,
102
+ is_manufacturer BOOLEAN DEFAULT FALSE,
103
+ manufacturing_certifications TEXT,
104
+ contact_name VARCHAR(255),
105
+ contact_email VARCHAR(100),
106
+ address VARCHAR(255),
107
+ country VARCHAR(100),
108
+ region_code VARCHAR(50),
109
+ phone VARCHAR(30),
110
+ last_order DATE,
111
+ key_supplier VARCHAR(3),
112
+ supply_reliability VARCHAR(3)
113
+ );
114
+
115
+ DROP TABLE IF EXISTS tmp_d_ebike_suppliers CASCADE;
116
+
117
+ CREATE TABLE tmp_d_ebike_suppliers (
118
+ supplier_id INTEGER,
119
+ supplier_name VARCHAR(255) NOT NULL,
120
+ is_manufacturer BOOLEAN DEFAULT FALSE,
121
+ manufacturing_certifications TEXT,
122
+ contact_name VARCHAR(255),
123
+ contact_email VARCHAR(100),
124
+ address VARCHAR(255),
125
+ country VARCHAR(100),
126
+ region_code VARCHAR(50),
127
+ phone VARCHAR(30),
128
+ last_order DATE,
129
+ key_supplier VARCHAR(3),
130
+ supply_reliability VARCHAR(3)
131
+ );
132
+
133
+ DROP TABLE IF EXISTS tmp_ebike_sales CASCADE;
134
+
135
+ CREATE TABLE tmp_ebike_sales (
136
+ sale_id INTEGER,
137
+ sale_date DATE,
138
+ customer_id INT,
139
+ supplier_id INT,
140
+ product_id INT,
141
+ quantity_sold INT,
142
+ sale_price DECIMAL(10,2),
143
+ total_amount DECIMAL(10,2),
144
+ discount_amount DECIMAL(10,2) DEFAULT 0,
145
+ adjusted_total_amount DECIMAL(10,2),
146
+ warranty_end_date DATE,
147
+ next_maintenance_date DATE,
148
+ return_reason TEXT
149
+ );
150
+
151
+ DROP TABLE IF EXISTS f_ebike_sales CASCADE;
152
+
153
+ CREATE TABLE f_ebike_sales (
154
+ sale_id INTEGER,
155
+ sale_date DATE,
156
+ customer_id INT,
157
+ supplier_id INT,
158
+ product_id INT,
159
+ quantity_sold INT,
160
+ sale_price DECIMAL(10,2),
161
+ total_amount DECIMAL(10,2),
162
+ discount_amount DECIMAL(10,2) DEFAULT 0,
163
+ adjusted_total_amount DECIMAL(10,2),
164
+ warranty_end_date DATE,
165
+ next_maintenance_date DATE,
166
+ return_reason TEXT
167
+ );
@@ -0,0 +1,100 @@
1
+ SET SEARCH_PATH TO {PROJECT_SCHEMA};
2
+
3
+ TRUNCATE TABLE f_ebike_sales;
4
+
5
+ INSERT INTO f_ebike_sales
6
+ (sale_id,
7
+ customer_id, supplier_id, product_id, quantity_sold, sale_price, total_amount,
8
+ discount_amount, adjusted_total_amount, return_reason,
9
+ sale_date, warranty_end_date, next_maintenance_date)
10
+ SELECT t.sale_id,
11
+ t.customer_id, t.supplier_id, t.product_id, t.quantity_sold, t.sale_price, t.total_amount,
12
+ t.discount_amount, t.adjusted_total_amount, t.return_reason,
13
+ t.sale_date + (SELECT (CURRENT_DATE - MAX(sale_date))::integer - 1 FROM tmp_ebike_sales),
14
+ t.warranty_end_date + (SELECT (CURRENT_DATE - MAX(sale_date))::integer - 1 FROM tmp_ebike_sales),
15
+ t.next_maintenance_date + (SELECT (CURRENT_DATE - MAX(sale_date))::integer - 1 FROM tmp_ebike_sales)
16
+ FROM tmp_ebike_sales t
17
+ LEFT JOIN f_ebike_sales fes ON t.sale_id = fes.sale_id
18
+ WHERE fes.sale_id IS NULL
19
+ AND t.sale_date <= '{MAX_DATE}';
20
+
21
+
22
+ TRUNCATE TABLE d_ebike_customers;
23
+
24
+ INSERT INTO d_ebike_customers
25
+ (customer_id, first_name, last_name, address, city, state, postal_code, country, customer_type, avg_age, income_level,
26
+ gender, occupation, marital_status, customer_note, sales_region, sales_territory, customer_decile, phone_number,
27
+ tax_id, credit_card, last_contact)
28
+ SELECT t.customer_id,
29
+ t.first_name,
30
+ t.last_name,
31
+ t.address,
32
+ t.city,
33
+ t.state,
34
+ t.postal_code,
35
+ t.country,
36
+ t.customer_type,
37
+ t.avg_age,
38
+ t.income_level,
39
+ t.gender,
40
+ t.occupation,
41
+ t.marital_status,
42
+ t.customer_note,
43
+ t.sales_region,
44
+ t.sales_territory,
45
+ t.customer_decile,
46
+ t.phone_number,
47
+ t.tax_id,
48
+ t.credit_card,
49
+ t.last_contact - (55 - (SELECT (CURRENT_DATE - MAX(last_contact)) FROM tmp_d_ebike_customers))
50
+ FROM tmp_d_ebike_customers t
51
+ WHERE t.customer_id <= '{MAX_CUSTOMER_ID_SEQ}';
52
+
53
+ UPDATE d_ebike_customers
54
+ SET last_contact = CASE WHEN '{ITERATION_NUMBER}' = 1 AND
55
+ current_date - last_contact <= 60 THEN last_contact - (62 - (current_date - last_contact))
56
+ ELSE last_contact END;
57
+
58
+ TRUNCATE TABLE d_ebike_products;
59
+
60
+ INSERT INTO d_ebike_products
61
+ (product_id, product_name, product_description, product_type, frame_size, battery_life, max_speed, weight_capacity,
62
+ color, wheel_size, gear_count, country_of_origin, price, max_discount)
63
+ SELECT t.product_id,
64
+ t.product_name,
65
+ t.product_description,
66
+ t.product_type,
67
+ t.frame_size,
68
+ t.battery_life,
69
+ t.max_speed,
70
+ t.weight_capacity,
71
+ t.color,
72
+ t.wheel_size,
73
+ t.gear_count,
74
+ t.country_of_origin,
75
+ t.price,
76
+ t.max_discount
77
+ FROM tmp_d_ebike_products t
78
+ WHERE product_id <= '{MAX_PRODUCT_ID_SEQ}';
79
+
80
+
81
+ TRUNCATE TABLE d_ebike_suppliers;
82
+
83
+ INSERT INTO d_ebike_suppliers
84
+ (supplier_id, supplier_name, is_manufacturer, manufacturing_certifications, contact_name, contact_email, address,
85
+ country, region_code, phone, last_order, key_supplier, supply_reliability)
86
+ SELECT t.supplier_id,
87
+ t.supplier_name,
88
+ t.is_manufacturer,
89
+ t.manufacturing_certifications,
90
+ t.contact_name,
91
+ t.contact_email,
92
+ t.address,
93
+ t.country,
94
+ t.region_code,
95
+ t.phone,
96
+ t.last_order,
97
+ t.key_supplier,
98
+ t.supply_reliability
99
+ FROM tmp_d_ebike_suppliers t
100
+ WHERE t.supplier_id <= '{MAX_SUPPLIER_ID_SEQ}';
@@ -0,0 +1,19 @@
1
+ DROP TABLE IF EXISTS tmp_test_definition CASCADE;
2
+
3
+ CREATE TEMPORARY TABLE tmp_test_definition
4
+ (
5
+ project_code varchar(30),
6
+ test_suite varchar(200),
7
+ schema_name varchar(100),
8
+ table_name varchar(100),
9
+ column_name varchar(500),
10
+ id uuid,
11
+ test_type varchar(200),
12
+ test_description varchar(1000),
13
+ test_action varchar(100),
14
+ test_active varchar(10),
15
+ lock_refresh varchar(10),
16
+ severity varchar(10),
17
+ test_parameter varchar(100),
18
+ test_parameter_value varchar(1000)
19
+ );
@@ -0,0 +1,38 @@
1
+ SELECT td.project_code, td.test_suite,
2
+ td.schema_name, td.table_name, td.column_name,
3
+ td.id::VARCHAR(50), td.test_type,
4
+ CASE WHEN td.test_description IS NOT NULL THEN td.test_description ELSE tt.test_description END
5
+ as test_description,
6
+ td.test_action,
7
+ td.test_active,
8
+ td.lock_refresh,
9
+ td.severity,
10
+ tt.default_parm_columns as test_parameters,
11
+ td.baseline_ct,
12
+ td.baseline_unique_ct,
13
+ td.baseline_value,
14
+ td.baseline_value_ct,
15
+ td.threshold_value,
16
+ td.baseline_sum,
17
+ td.baseline_avg,
18
+ td.baseline_sd,
19
+ td.subset_condition,
20
+ td.groupby_names,
21
+ td.having_condition,
22
+ td.window_date_column,
23
+ td.window_days,
24
+ td.match_schema_name,
25
+ td.match_table_name,
26
+ td.match_column_names,
27
+ td.match_subset_condition,
28
+ td.match_groupby_names,
29
+ td.match_having_condition,
30
+ td.custom_query
31
+
32
+ FROM test_definitions td
33
+ INNER JOIN test_types tt
34
+ ON (td.test_type = tt.test_type)
35
+ WHERE project_code = '{PROJECT_CODE}'
36
+ AND test_suite = '{TEST_SUITE}'
37
+ ORDER BY td.project_code, td.test_suite,
38
+ td.schema_name, td.table_name, td.column_name, td.test_type;
@@ -0,0 +1,184 @@
1
+ DROP TABLE IF EXISTS tmp_stg_test_definitions CASCADE;
2
+
3
+ CREATE TEMPORARY TABLE tmp_stg_test_definitions
4
+ (
5
+ id uuid,
6
+ cat_test_id bigint,
7
+ project_code varchar(30),
8
+ table_groups_id uuid,
9
+ profile_run_id uuid,
10
+ test_type varchar(200),
11
+ test_suite varchar(200),
12
+ test_description varchar(1000),
13
+ test_action varchar(100),
14
+ schema_name varchar(100),
15
+ table_name varchar(100),
16
+ column_name varchar(500),
17
+ skip_errors integer,
18
+ baseline_ct varchar(1000),
19
+ baseline_unique_ct varchar(1000),
20
+ baseline_value varchar(1000),
21
+ baseline_value_ct varchar(1000),
22
+ threshold_value varchar(1000),
23
+ baseline_sum varchar(1000),
24
+ baseline_avg varchar(1000),
25
+ baseline_sd varchar(1000),
26
+ subset_condition varchar(500),
27
+ groupby_names varchar(200),
28
+ having_condition varchar(500),
29
+ window_date_column varchar(100),
30
+ window_days integer,
31
+ match_schema_name varchar(100),
32
+ match_table_name varchar(100),
33
+ match_column_names varchar(200),
34
+ match_subset_condition varchar(500),
35
+ match_groupby_names varchar(200),
36
+ match_having_condition varchar(500),
37
+ test_mode varchar(20),
38
+ custom_query varchar(4000),
39
+ test_active varchar(10),
40
+ severity varchar(10),
41
+ watch_level varchar(10),
42
+ check_result varchar(500),
43
+ lock_refresh varchar(10),
44
+ last_auto_gen_date timestamp,
45
+ profiling_as_of_date timestamp
46
+ );
47
+
48
+
49
+ INSERT INTO tmp_stg_test_definitions (project_code, test_suite, schema_name, table_name, column_name,
50
+ id, test_type, test_description, test_action, test_active,lock_refresh, severity,
51
+ baseline_ct,baseline_unique_ct,baseline_value,baseline_value_ct,threshold_value,
52
+ baseline_sum,baseline_avg,baseline_sd,subset_condition,groupby_names,having_condition,
53
+ window_date_column,window_days,match_schema_name,match_table_name,match_column_names,
54
+ match_subset_condition,match_groupby_names, match_having_condition )
55
+ SELECT project_code,
56
+ test_suite,
57
+ schema_name,
58
+ table_name,
59
+ column_name,
60
+ id,
61
+ test_type,
62
+ test_description,
63
+ test_action,
64
+ CASE WHEN lower(test_active) = 'none' THEN 'N' ELSE test_active END as test_active,
65
+ CASE WHEN lower(lock_refresh) = 'none' THEN 'N' ELSE lock_refresh END as lock_refresh,
66
+ CASE WHEN lower(severity) IN ('warning','fail','ignore') THEN initcap(severity) ELSE NULL END as severity,
67
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_ct' ) AS baseline_ct,
68
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_unique_ct' ) AS baseline_unique_ct,
69
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_value' ) AS baseline_value,
70
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_value_ct' ) AS baseline_value_ct,
71
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'threshold_value' ) AS threshold_value,
72
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_sum' ) AS baseline_sum,
73
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_avg' ) AS baseline_avg,
74
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'baseline_sd' ) AS baseline_sd,
75
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'subset_condition' ) AS subset_condition,
76
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'groupby_names' ) AS groupby_names,
77
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'having_condition' ) AS having_condition,
78
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'window_date_column' ) AS window_date_column,
79
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'window_days' ) :: integer AS window_days,
80
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_schema_name' ) AS match_schema_name,
81
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_table_name' ) AS match_table_name,
82
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_column_names' ) AS match_column_names,
83
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_subset_condition' ) AS match_subset_condition,
84
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_groupby_names' ) AS match_groupby_names,
85
+ MAX(test_parameter_value) FILTER( WHERE test_parameter = 'match_having_condition' ) AS match_having_condition
86
+ FROM tmp_test_definition
87
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
88
+ ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;
89
+
90
+
91
+ --- UPDATE
92
+
93
+ UPDATE test_definitions
94
+ SET test_active = CASE WHEN lower(c.test_active) = 'none' THEN 'N' ELSE c.test_active END,
95
+ lock_refresh = CASE WHEN lower(c.lock_refresh) = 'none' THEN 'N' ELSE c.lock_refresh END,
96
+ severity = CASE WHEN lower(c.severity) IN ('warning','fail','ignore') THEN initcap(c.severity) ELSE NULL END,
97
+ last_manual_update = current_timestamp ,
98
+ baseline_ct = c.baseline_ct ,
99
+ baseline_unique_ct = c.baseline_unique_ct ,
100
+ baseline_value = c.baseline_value ,
101
+ baseline_value_ct = c.baseline_value_ct ,
102
+ threshold_value = c.threshold_value ,
103
+ baseline_sum = c.baseline_sum ,
104
+ baseline_avg = c.baseline_avg ,
105
+ baseline_sd = c.baseline_sd ,
106
+ subset_condition = c.subset_condition ,
107
+ groupby_names = c.groupby_names ,
108
+ having_condition = c.having_condition ,
109
+ window_date_column = c.window_date_column ,
110
+ window_days = c.window_days ,
111
+ match_schema_name = c.match_schema_name ,
112
+ match_table_name = c.match_table_name ,
113
+ match_column_names = c.match_column_names ,
114
+ match_subset_condition = c.match_subset_condition,
115
+ match_groupby_names = c.match_groupby_names
116
+ FROM ( SELECT b.* FROM tmp_stg_test_definitions b
117
+ LEFT JOIN test_definitions a
118
+ ON a.project_code = b.project_code
119
+ AND a.test_suite = b.test_suite
120
+ AND a.schema_name = b.schema_name
121
+ AND a.table_name = b.table_name
122
+ AND a.column_name = b.column_name
123
+ AND a.test_type = b.test_type
124
+ WHERE (a.test_active != b.test_active)
125
+ OR (a.lock_refresh != b.lock_refresh)
126
+ OR (coalesce(a.severity,'') != coalesce(b.severity,''))
127
+ OR (a.baseline_ct != b.baseline_ct )
128
+ OR (a.baseline_unique_ct != b.baseline_unique_ct )
129
+ OR (a.baseline_value != b.baseline_value )
130
+ OR (a.baseline_value_ct != b.baseline_value_ct )
131
+ OR (a.threshold_value != b.threshold_value )
132
+ OR (a.baseline_sum != b.baseline_sum )
133
+ OR (a.baseline_avg != b.baseline_avg )
134
+ OR (a.baseline_sd != b.baseline_sd )
135
+ OR (a.subset_condition != b.subset_condition )
136
+ OR (a.groupby_names != b.groupby_names )
137
+ OR (a.having_condition != b.having_condition )
138
+ OR (a.window_date_column != b.window_date_column )
139
+ OR (a.window_days != b.window_days )
140
+ OR (a.match_schema_name != b.match_schema_name )
141
+ OR (a.match_table_name != b.match_table_name )
142
+ OR (a.match_column_names != b.match_column_names )
143
+ OR (a.match_subset_condition != b.match_subset_condition)
144
+ OR (a.match_groupby_names != b.match_groupby_names )
145
+ ) c
146
+ WHERE test_definitions.project_code = c.project_code
147
+ AND test_definitions.test_suite = c.test_suite
148
+ AND test_definitions.schema_name = c.schema_name
149
+ AND test_definitions.table_name = c.table_name
150
+ AND test_definitions.column_name = c.column_name
151
+ AND test_definitions.test_type = c.test_type ;
152
+
153
+
154
+ -- INSERT
155
+ INSERT INTO test_definitions (project_code, test_suite, schema_name, table_name, column_name,
156
+ test_type, test_action, test_active, lock_refresh, severity, last_manual_update,
157
+ baseline_ct,baseline_unique_ct,baseline_value,baseline_value_ct,threshold_value,
158
+ baseline_sum,baseline_avg,baseline_sd,subset_condition,groupby_names,having_condition,
159
+ window_date_column,window_days,match_schema_name,match_table_name,match_column_names,
160
+ match_subset_condition,match_groupby_names, match_having_condition )
161
+ SELECT a.project_code, a.test_suite, a.schema_name, a.table_name, a.column_name,
162
+ a.test_type,
163
+ CASE WHEN lower(a.test_action) = 'none' THEN NULL ELSE a.test_action END as test_action,
164
+ CASE WHEN lower(a.test_active) = 'none' THEN 'N' ELSE a.test_active END as test_active,
165
+ CASE WHEN lower(a.lock_refresh) = 'none' THEN 'N' ELSE a.lock_refresh END as lock_refresh,
166
+ CASE WHEN lower(a.severity) IN ('warning','fail','ignore') THEN initcap(a.severity) ELSE NULL END as severity,
167
+ current_timestamp as last_manual_update,
168
+ a.baseline_ct,a.baseline_unique_ct,a.baseline_value,a.baseline_value_ct,a.threshold_value,
169
+ a.baseline_sum,a.baseline_avg,a.baseline_sd,a.subset_condition,a.groupby_names,a.having_condition,
170
+ a.window_date_column,a.window_days,a.match_schema_name,a.match_table_name,a.match_column_names,
171
+ a.match_subset_condition,a.match_groupby_names, a.match_having_condition
172
+ FROM tmp_stg_test_definitions a
173
+ LEFT JOIN test_definitions b
174
+ ON a.project_code = b.project_code
175
+ AND a.test_suite = b.test_suite
176
+ AND a.schema_name = b.schema_name
177
+ AND a.table_name = b.table_name
178
+ AND a.column_name = b.column_name
179
+ AND a.test_type = b.test_type
180
+ WHERE a.id IS NULL AND b.id is NULL;
181
+
182
+ DROP TABLE tmp_test_definition CASCADE;
183
+
184
+ DROP TABLE tmp_stg_test_definitions CASCADE;
@@ -0,0 +1,5 @@
1
+ update test_definitions
2
+ set test_active = 'N'
3
+ where project_code = '{PROJECT_CODE}'
4
+ and test_suite = '{TEST_SUITE}'
5
+ and test_active = 'D';
@@ -0,0 +1,64 @@
1
+ /*
2
+ Mark Test inactive for Missing columns with update status
3
+ */
4
+ with test_columns as
5
+ (SELECT DISTINCT schema_name || '.' || table_name || '.' || column_name AS columns
6
+ FROM ( SELECT cat_test_id,
7
+ project_code,
8
+ test_suite,
9
+ schema_name,
10
+ table_name,
11
+ UNNEST(STRING_TO_ARRAY(all_columns, '~|~')) AS column_name
12
+ FROM ( SELECT cat_test_id,
13
+ project_code,
14
+ test_suite,
15
+ schema_name,
16
+ table_name,
17
+ CONCAT_WS('~|~', column_name,
18
+ groupby_names,
19
+ window_date_column) AS all_columns
20
+ FROM test_definitions d
21
+ INNER JOIN test_types t
22
+ ON d.test_type = t.test_type
23
+ WHERE project_code = '{PROJECT_CODE}'
24
+ AND test_suite = '{TEST_SUITE}'
25
+ AND t.test_scope = 'column'
26
+
27
+ UNION
28
+ SELECT cat_test_id,
29
+ project_code,
30
+ test_suite,
31
+ match_schema_name AS schema_name,
32
+ match_table_name AS table_name,
33
+ CONCAT_WS('~|~',
34
+ match_column_names,
35
+ match_groupby_names) AS all_columns
36
+ FROM test_definitions d
37
+ INNER JOIN test_types t
38
+ ON d.test_type = t.test_type
39
+ WHERE project_code = '{PROJECT_CODE}'
40
+ AND test_suite = '{TEST_SUITE}'
41
+ AND t.test_scope = 'column') a ) b)
42
+ update test_definitions
43
+ set test_active = '{FLAG}',
44
+ test_definition_status = 'Inactivated {RUN_DATE}: Missing Column'
45
+ where cat_test_id in (select distinct cat_test_id
46
+ from test_columns
47
+ where lower(columns) in
48
+ ({MISSING_COLUMNS}));
49
+
50
+
51
+ /*
52
+ Mark Test inactive for Missing table with update status
53
+ */
54
+ with test_columns as
55
+ (select distinct cat_test_id, schema_name || '.' || table_name || '.' || column_name as columns
56
+ from test_definitions
57
+ where project_code = '{PROJECT_CODE}'
58
+ and test_suite = '{TEST_SUITE}'
59
+ and lower(schema_name || '.' || table_name) in ({MISSING_TABLES}))
60
+ update test_definitions
61
+ set test_active = '{FLAG}',
62
+ test_definition_status = 'Inactivated {RUN_DATE}: Missing Table'
63
+ where cat_test_id in (select distinct cat_test_id
64
+ from test_columns);
@@ -0,0 +1,3 @@
1
+ select concat(concat(concat(table_schema, '.'), concat(table_name, '.')), column_name) as columns
2
+ from information_schema.columns
3
+ where table_schema in ({TEST_SCHEMAS});
@@ -0,0 +1,65 @@
1
+ SELECT DISTINCT schema_name || '.' || table_name || '.' || column_name AS columns
2
+ FROM ( SELECT cat_test_id,
3
+ project_code,
4
+ test_suite,
5
+ schema_name AS schema_name,
6
+ table_name AS table_name,
7
+ TRIM(UNNEST(STRING_TO_ARRAY(column_name, ','))) as column_name
8
+ FROM test_definitions d
9
+ INNER JOIN test_types t
10
+ ON d.test_type = t.test_type
11
+ WHERE project_code = '{PROJECT_CODE}'
12
+ AND test_suite = '{TEST_SUITE}'
13
+ AND t.test_scope IN ('column', 'referential')
14
+ UNION
15
+ SELECT cat_test_id,
16
+ project_code,
17
+ test_suite,
18
+ schema_name AS schema_name,
19
+ table_name AS table_name,
20
+ TRIM(UNNEST(STRING_TO_ARRAY(groupby_names, ','))) as column_name
21
+ FROM test_definitions d
22
+ INNER JOIN test_types t
23
+ ON d.test_type = t.test_type
24
+ WHERE project_code = '{PROJECT_CODE}'
25
+ AND test_suite = '{TEST_SUITE}'
26
+ AND t.test_scope IN ('column', 'referential')
27
+ UNION
28
+ SELECT cat_test_id,
29
+ project_code,
30
+ test_suite,
31
+ schema_name AS schema_name,
32
+ table_name AS table_name,
33
+ TRIM(UNNEST(STRING_TO_ARRAY(window_date_column, ','))) as column_name
34
+ FROM test_definitions d
35
+ INNER JOIN test_types t
36
+ ON d.test_type = t.test_type
37
+ WHERE project_code = '{PROJECT_CODE}'
38
+ AND test_suite = '{TEST_SUITE}'
39
+ AND t.test_scope IN ('column', 'referential')
40
+ UNION
41
+ SELECT cat_test_id,
42
+ project_code,
43
+ test_suite,
44
+ match_schema_name AS schema_name,
45
+ match_table_name AS table_name,
46
+ TRIM(UNNEST(STRING_TO_ARRAY(match_column_names, ','))) as column_name
47
+ FROM test_definitions d
48
+ INNER JOIN test_types t
49
+ ON d.test_type = t.test_type
50
+ WHERE project_code = '{PROJECT_CODE}'
51
+ AND test_suite = '{TEST_SUITE}'
52
+ AND t.test_scope = 'referential'
53
+ UNION
54
+ SELECT cat_test_id,
55
+ project_code,
56
+ test_suite,
57
+ match_schema_name AS schema_name,
58
+ match_table_name AS table_name,
59
+ TRIM(UNNEST(STRING_TO_ARRAY(match_groupby_names, ','))) as column_name
60
+ FROM test_definitions d
61
+ INNER JOIN test_types t
62
+ ON d.test_type = t.test_type
63
+ WHERE project_code = '{PROJECT_CODE}'
64
+ AND test_suite = '{TEST_SUITE}'
65
+ AND t.test_scope = 'referential' ) cols;
@@ -0,0 +1,22 @@
1
+ INSERT INTO test_results
2
+ (project_code, test_suite, test_type, test_definition_id,
3
+ schema_name, table_name, column_names, test_time, test_run_id,
4
+ input_parameters, result_code, result_message, result_measure)
5
+ SELECT '{PROJECT_CODE}' as project_code,
6
+ '{TEST_SUITE}' as test_suite,
7
+ test_type,
8
+ id,
9
+ schema_name,
10
+ table_name,
11
+ column_name,
12
+ '{RUN_DATE}' as test_time,
13
+ '{TEST_RUN_ID}' as test_run_id,
14
+ NULL as input_parameters,
15
+ 0 as result_code,
16
+ -- TODO: show only missing columns referenced in this test
17
+ left('ERROR - TEST COLUMN MISSING: {MISSING_COLUMNS_NO_QUOTES}', 470) AS result_message,
18
+ NULL as result_measure
19
+ FROM test_definitions
20
+ WHERE test_active = '-1'
21
+ AND project_code = '{PROJECT_CODE}'
22
+ AND test_suite = '{TEST_SUITE}';
testgen/ui/__init__.py ADDED
File without changes