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.
- dataops_testgen-2.2.0.dist-info/LICENSE +203 -0
- dataops_testgen-2.2.0.dist-info/METADATA +287 -0
- dataops_testgen-2.2.0.dist-info/NOTICE +5 -0
- dataops_testgen-2.2.0.dist-info/RECORD +270 -0
- dataops_testgen-2.2.0.dist-info/WHEEL +5 -0
- dataops_testgen-2.2.0.dist-info/entry_points.txt +2 -0
- dataops_testgen-2.2.0.dist-info/top_level.txt +1 -0
- testgen/__init__.py +0 -0
- testgen/__main__.py +770 -0
- testgen/commands/__init__.py +0 -0
- testgen/commands/queries/__init__.py +0 -0
- testgen/commands/queries/execute_cat_tests_query.py +95 -0
- testgen/commands/queries/execute_tests_query.py +160 -0
- testgen/commands/queries/generate_tests_query.py +94 -0
- testgen/commands/queries/profiling_query.py +366 -0
- testgen/commands/queries/test_parameter_validation_query.py +88 -0
- testgen/commands/run_execute_cat_tests.py +162 -0
- testgen/commands/run_execute_tests.py +168 -0
- testgen/commands/run_generate_tests.py +107 -0
- testgen/commands/run_get_entities.py +122 -0
- testgen/commands/run_launch_db_config.py +84 -0
- testgen/commands/run_observability_exporter.py +330 -0
- testgen/commands/run_profiling_bridge.py +495 -0
- testgen/commands/run_quick_start.py +168 -0
- testgen/commands/run_setup_profiling_tools.py +96 -0
- testgen/commands/run_test_definition.py +146 -0
- testgen/commands/run_test_parameter_validation.py +135 -0
- testgen/commands/run_upgrade_db_config.py +156 -0
- testgen/common/__init__.py +8 -0
- testgen/common/clean_sql.py +53 -0
- testgen/common/credentials.py +25 -0
- testgen/common/database/__init__.py +0 -0
- testgen/common/database/database_service.py +629 -0
- testgen/common/database/flavor/__init__.py +0 -0
- testgen/common/database/flavor/flavor_service.py +75 -0
- testgen/common/database/flavor/mssql_flavor_service.py +34 -0
- testgen/common/database/flavor/postgresql_flavor_service.py +5 -0
- testgen/common/database/flavor/redshift_flavor_service.py +22 -0
- testgen/common/database/flavor/snowflake_flavor_service.py +69 -0
- testgen/common/database/flavor/trino_flavor_service.py +21 -0
- testgen/common/date_service.py +68 -0
- testgen/common/display_service.py +85 -0
- testgen/common/docker_service.py +76 -0
- testgen/common/encrypt.py +55 -0
- testgen/common/get_pipeline_parms.py +57 -0
- testgen/common/logs.py +79 -0
- testgen/common/process_service.py +62 -0
- testgen/common/read_file.py +69 -0
- testgen/settings.py +440 -0
- testgen/template/dbsetup/010_create_base_schema.sql +2 -0
- testgen/template/dbsetup/020_create_standard_functions_sprocs.sql +179 -0
- testgen/template/dbsetup/030_initialize_new_schema_structure.sql +735 -0
- testgen/template/dbsetup/040_populate_new_schema_project.sql +59 -0
- testgen/template/dbsetup/050_populate_new_schema_metadata.sql +1517 -0
- testgen/template/dbsetup/060_create_standard_views.sql +248 -0
- testgen/template/dbsetup/070_create_default_users.sql +17 -0
- testgen/template/dbsetup/075_grant_role_rights.sql +43 -0
- testgen/template/dbsetup/080_set_current_revision.sql +5 -0
- testgen/template/dbupgrade/0100_incremental_upgrade.sql +5 -0
- testgen/template/dbupgrade/0101_incremental_upgrade.sql +15 -0
- testgen/template/dbupgrade/0102_incremental_upgrade.sql +4 -0
- testgen/template/dbupgrade/0103_incremental_upgrade.sql +22 -0
- testgen/template/dbupgrade/0104_incremental_upgrade.sql +44 -0
- testgen/template/dbupgrade/0105_incremental_upgrade.sql +1 -0
- testgen/template/dbupgrade/0106_incremental_upgrade.sql +5 -0
- testgen/template/dbupgrade/0107_incremental_upgrade.sql +3 -0
- testgen/template/dbupgrade_helpers/get_tg_revision.sql +2 -0
- testgen/template/exec_cat_tests/ex_cat_build_agg_table_tests.sql +116 -0
- testgen/template/exec_cat_tests/ex_cat_get_distinct_tables.sql +11 -0
- testgen/template/exec_cat_tests/ex_cat_results_parse.sql +69 -0
- testgen/template/exec_cat_tests/ex_cat_retrieve_agg_test_parms.sql +6 -0
- testgen/template/exec_cat_tests/ex_cat_test_query.sql +8 -0
- testgen/template/execution/ex_finalize_test_run_results.sql +37 -0
- testgen/template/execution/ex_get_tests_non_cat.sql +47 -0
- testgen/template/execution/ex_update_test_record_in_testrun_table.sql +27 -0
- testgen/template/execution/ex_write_test_record_to_testrun_table.sql +6 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_no_drops_generic.sql +48 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_num_incr_generic.sql +34 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_above_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_percent_within_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_aggregate_match_same_generic.sql +49 -0
- testgen/template/flavors/generic/exec_query_tests/ex_custom_query_generic.sql +39 -0
- testgen/template/flavors/generic/exec_query_tests/ex_data_match_2way_generic.sql +58 -0
- testgen/template/flavors/generic/exec_query_tests/ex_data_match_generic.sql +44 -0
- testgen/template/flavors/generic/exec_query_tests/ex_prior_match_generic.sql +37 -0
- testgen/template/flavors/generic/exec_query_tests/ex_relative_entropy_generic.sql +53 -0
- testgen/template/flavors/generic/exec_query_tests/ex_window_match_no_drops_generic.sql +46 -0
- testgen/template/flavors/generic/exec_query_tests/ex_window_match_same_generic.sql +59 -0
- testgen/template/flavors/generic/profiling/contingency_counts.sql +3 -0
- testgen/template/flavors/generic/validate_tests/ex_get_project_column_list_generic.sql +3 -0
- testgen/template/flavors/mssql/exec_query_tests/ex_relative_entropy_mssql.sql +53 -0
- testgen/template/flavors/mssql/profiling/project_ddf_query_mssql.sql +35 -0
- testgen/template/flavors/mssql/profiling/project_profiling_query_mssql.yaml +246 -0
- testgen/template/flavors/mssql/profiling/project_secondary_profiling_query_mssql.sql +36 -0
- testgen/template/flavors/mssql/setup_profiling_tools/00_drop_existing_functions_mssql.sql +8 -0
- testgen/template/flavors/mssql/setup_profiling_tools/01_create_functions_mssql.sql +12 -0
- testgen/template/flavors/mssql/setup_profiling_tools/02_create_functions_mssql.sql +54 -0
- testgen/template/flavors/mssql/setup_profiling_tools/create_qc_schema_mssql.sql +4 -0
- testgen/template/flavors/mssql/setup_profiling_tools/grant_execute_privileges_mssql.sql +1 -0
- testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_no_drops_postgresql.sql +46 -0
- testgen/template/flavors/postgresql/exec_query_tests/ex_window_match_same_postgresql.sql +59 -0
- testgen/template/flavors/postgresql/profiling/project_ddf_query_postgresql.sql +42 -0
- testgen/template/flavors/postgresql/profiling/project_profiling_query_postgresql.yaml +225 -0
- testgen/template/flavors/postgresql/profiling/project_secondary_profiling_query_postgresql.sql +28 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/create_functions_postgresql.sql +157 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/create_qc_schema_postgresql.sql +1 -0
- testgen/template/flavors/postgresql/setup_profiling_tools/grant_execute_privileges_postgresql.sql +2 -0
- testgen/template/flavors/redshift/profiling/project_ddf_query_redshift.sql +38 -0
- testgen/template/flavors/redshift/profiling/project_profiling_query_redshift.yaml +221 -0
- testgen/template/flavors/redshift/profiling/project_secondary_profiling_query_redshift.sql +29 -0
- testgen/template/flavors/redshift/setup_profiling_tools/create_functions_redshift.sql +115 -0
- testgen/template/flavors/redshift/setup_profiling_tools/create_qc_schema_redshift.sql +1 -0
- testgen/template/flavors/redshift/setup_profiling_tools/grant_execute_privileges_redshift.sql +2 -0
- testgen/template/flavors/snowflake/profiling/project_ddf_query_snowflake.sql +38 -0
- testgen/template/flavors/snowflake/profiling/project_profiling_query_snowflake.yaml +220 -0
- testgen/template/flavors/snowflake/profiling/project_secondary_profiling_query_snowflake.sql +29 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/create_functions_snowflake.sql +69 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/create_qc_schema_snowflake.sql +1 -0
- testgen/template/flavors/snowflake/setup_profiling_tools/grant_execute_privileges_snowflake.sql +6 -0
- testgen/template/flavors/trino/profiling/project_profiling_query_trino.yaml +219 -0
- testgen/template/flavors/trino/setup_profiling_tools/create_functions_trino.sql +92 -0
- testgen/template/flavors/trino/setup_profiling_tools/create_qc_schema_trino.sql +1 -0
- testgen/template/gen_funny_cat_tests/gen_test_constant.sql +104 -0
- testgen/template/gen_funny_cat_tests/gen_test_distinct_value_ct.sql +98 -0
- testgen/template/gen_funny_cat_tests/gen_test_row_ct.sql +57 -0
- testgen/template/gen_funny_cat_tests/gen_test_row_ct_pct.sql +59 -0
- testgen/template/generation/gen_delete_old_tests.sql +5 -0
- testgen/template/generation/gen_insert_test_suite.sql +5 -0
- testgen/template/generation/gen_retrieve_or_insert_test_suite.sql +58 -0
- testgen/template/generation/gen_standard_test_type_list.sql +13 -0
- testgen/template/generation/gen_standard_tests.sql +48 -0
- testgen/template/get_entities/get_connection.sql +21 -0
- testgen/template/get_entities/get_connections_list.sql +9 -0
- testgen/template/get_entities/get_latest.sql +4 -0
- testgen/template/get_entities/get_profile.sql +12 -0
- testgen/template/get_entities/get_profile_info.sql +17 -0
- testgen/template/get_entities/get_profile_list.sql +17 -0
- testgen/template/get_entities/get_profile_screen.sql +275 -0
- testgen/template/get_entities/get_project_list.sql +6 -0
- testgen/template/get_entities/get_table_group_list.sql +10 -0
- testgen/template/get_entities/get_test_generation_list.sql +18 -0
- testgen/template/get_entities/get_test_info.sql +41 -0
- testgen/template/get_entities/get_test_results_for_run_cli.sql +16 -0
- testgen/template/get_entities/get_test_run_list.sql +24 -0
- testgen/template/get_entities/get_test_suite.sql +13 -0
- testgen/template/get_entities/get_test_suite_list.sql +18 -0
- testgen/template/get_entities/list_test_types.sql +4 -0
- testgen/template/observability/get_event_data.sql +23 -0
- testgen/template/observability/get_test_results.sql +41 -0
- testgen/template/observability/update_test_results_exported_to_observability.sql +12 -0
- testgen/template/parms/parms_profiling.sql +34 -0
- testgen/template/parms/parms_test_execution.sql +13 -0
- testgen/template/parms/parms_test_gen.sql +23 -0
- testgen/template/profiling/contingency_columns.sql +7 -0
- testgen/template/profiling/datatype_suggestions.sql +56 -0
- testgen/template/profiling/functional_datatype.sql +523 -0
- testgen/template/profiling/functional_tabletype_stage.sql +48 -0
- testgen/template/profiling/functional_tabletype_update.sql +8 -0
- testgen/template/profiling/pii_flag.sql +133 -0
- testgen/template/profiling/profile_anomalies_screen_column.sql +22 -0
- testgen/template/profiling/profile_anomalies_screen_multi_column.sql +58 -0
- testgen/template/profiling/profile_anomalies_screen_table.sql +22 -0
- testgen/template/profiling/profile_anomalies_screen_table_dates.sql +30 -0
- testgen/template/profiling/profile_anomalies_screen_variants.sql +40 -0
- testgen/template/profiling/profile_anomaly_types_get.sql +3 -0
- testgen/template/profiling/project_get_table_sample_count.sql +22 -0
- testgen/template/profiling/project_profile_run_record_insert.sql +8 -0
- testgen/template/profiling/project_profile_run_record_update.sql +5 -0
- testgen/template/profiling/project_profile_run_record_update_status.sql +5 -0
- testgen/template/profiling/project_update_profile_results_to_estimates.sql +32 -0
- testgen/template/profiling/refresh_anomalies.sql +33 -0
- testgen/template/profiling/refresh_data_chars_from_profiling.sql +156 -0
- testgen/template/profiling/secondary_profiling_columns.sql +12 -0
- testgen/template/profiling/secondary_profiling_delete.sql +4 -0
- testgen/template/profiling/secondary_profiling_update.sql +18 -0
- testgen/template/quick_start/populate_target_data.sql +1077 -0
- testgen/template/quick_start/recreate_target_data_schema.sql +167 -0
- testgen/template/quick_start/update_target_data.sql +100 -0
- testgen/template/updates/create_tmp_test_definition.sql +19 -0
- testgen/template/updates/get_test_def_parms.sql +38 -0
- testgen/template/updates/populate_stg_test_definitions.sql +184 -0
- testgen/template/validate_tests/ex_disable_tests_test_definitions.sql +5 -0
- testgen/template/validate_tests/ex_flag_tests_test_definitions.sql +64 -0
- testgen/template/validate_tests/ex_get_project_column_list_generic.sql +3 -0
- testgen/template/validate_tests/ex_get_test_column_list_tg.sql +65 -0
- testgen/template/validate_tests/ex_write_test_val_errors.sql +22 -0
- testgen/ui/__init__.py +0 -0
- testgen/ui/app.py +98 -0
- testgen/ui/assets/dk_logo.svg +46 -0
- testgen/ui/assets/question_mark.png +0 -0
- testgen/ui/assets/scripts.js +68 -0
- testgen/ui/assets/style.css +140 -0
- testgen/ui/bootstrap.py +109 -0
- testgen/ui/components/__init__.py +0 -0
- testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu4mxK.woff2 +0 -0
- testgen/ui/components/frontend/css/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 +0 -0
- testgen/ui/components/frontend/css/material-symbols-rounded.css +24 -0
- testgen/ui/components/frontend/css/material-symbols-rounded.woff2 +0 -0
- testgen/ui/components/frontend/css/roboto-font-faces.css +35 -0
- testgen/ui/components/frontend/css/shared.css +36 -0
- testgen/ui/components/frontend/img/dk_logo.svg +46 -0
- testgen/ui/components/frontend/index.html +17 -0
- testgen/ui/components/frontend/js/components/breadcrumbs.js +86 -0
- testgen/ui/components/frontend/js/components/button.js +66 -0
- testgen/ui/components/frontend/js/components/location.js +62 -0
- testgen/ui/components/frontend/js/components/select.js +75 -0
- testgen/ui/components/frontend/js/components/sidebar.js +358 -0
- testgen/ui/components/frontend/js/main.js +99 -0
- testgen/ui/components/frontend/js/streamlit.js +19 -0
- testgen/ui/components/frontend/js/van.min.js +1 -0
- testgen/ui/components/utils/__init__.py +0 -0
- testgen/ui/components/utils/callbacks.py +51 -0
- testgen/ui/components/utils/component.py +13 -0
- testgen/ui/components/widgets/__init__.py +6 -0
- testgen/ui/components/widgets/breadcrumbs.py +32 -0
- testgen/ui/components/widgets/location.py +65 -0
- testgen/ui/components/widgets/modal.py +97 -0
- testgen/ui/components/widgets/sidebar.py +69 -0
- testgen/ui/navigation/__init__.py +0 -0
- testgen/ui/navigation/menu.py +42 -0
- testgen/ui/navigation/page.py +20 -0
- testgen/ui/navigation/router.py +63 -0
- testgen/ui/queries/__init__.py +0 -0
- testgen/ui/queries/authentication_queries.py +47 -0
- testgen/ui/queries/connection_queries.py +121 -0
- testgen/ui/queries/profiling_queries.py +148 -0
- testgen/ui/queries/project_queries.py +9 -0
- testgen/ui/queries/table_group_queries.py +186 -0
- testgen/ui/queries/test_definition_queries.py +270 -0
- testgen/ui/queries/test_run_queries.py +32 -0
- testgen/ui/queries/test_suite_queries.py +145 -0
- testgen/ui/scripts/__init__.py +0 -0
- testgen/ui/scripts/patch_streamlit.py +111 -0
- testgen/ui/services/__init__.py +0 -0
- testgen/ui/services/authentication_service.py +119 -0
- testgen/ui/services/connection_service.py +220 -0
- testgen/ui/services/database_service.py +282 -0
- testgen/ui/services/form_service.py +1008 -0
- testgen/ui/services/javascript_service.py +44 -0
- testgen/ui/services/query_service.py +316 -0
- testgen/ui/services/string_service.py +12 -0
- testgen/ui/services/table_group_service.py +130 -0
- testgen/ui/services/test_definition_service.py +117 -0
- testgen/ui/services/test_run_service.py +13 -0
- testgen/ui/services/test_suite_service.py +76 -0
- testgen/ui/services/toolbar_service.py +77 -0
- testgen/ui/session.py +46 -0
- testgen/ui/views/__init__.py +0 -0
- testgen/ui/views/app_log_modal.py +92 -0
- testgen/ui/views/connections.py +72 -0
- testgen/ui/views/connections_base.py +367 -0
- testgen/ui/views/login.py +40 -0
- testgen/ui/views/not_found.py +16 -0
- testgen/ui/views/overview.py +34 -0
- testgen/ui/views/profiling_anomalies.py +501 -0
- testgen/ui/views/profiling_details.py +335 -0
- testgen/ui/views/profiling_modal.py +40 -0
- testgen/ui/views/profiling_results.py +206 -0
- testgen/ui/views/profiling_summary.py +177 -0
- testgen/ui/views/project_settings.py +74 -0
- testgen/ui/views/table_groups.py +530 -0
- testgen/ui/views/test_definitions.py +1020 -0
- testgen/ui/views/test_results.py +908 -0
- testgen/ui/views/test_runs.py +195 -0
- testgen/ui/views/test_suites.py +545 -0
- testgen/utils/__init__.py +0 -0
- testgen/utils/plugins.py +17 -0
- testgen/utils/singleton.py +14 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
-- Insert new tests where a locked test is not already present
|
|
2
|
+
INSERT INTO test_definitions (project_code, table_groups_id, profile_run_id, test_type, test_suite, test_suite_id,
|
|
3
|
+
schema_name, table_name,
|
|
4
|
+
skip_errors, threshold_value,
|
|
5
|
+
last_auto_gen_date, test_active, baseline_ct, profiling_as_of_date)
|
|
6
|
+
WITH last_run AS (SELECT r.table_groups_id, MAX(run_date) AS last_run_date
|
|
7
|
+
FROM profile_results p
|
|
8
|
+
INNER JOIN profiling_runs r
|
|
9
|
+
ON (p.profile_run_id = r.id)
|
|
10
|
+
INNER JOIN test_suites tg
|
|
11
|
+
ON p.project_code = tg.project_code
|
|
12
|
+
AND p.connection_id = tg.connection_id
|
|
13
|
+
WHERE p.project_code = '{PROJECT_CODE}'
|
|
14
|
+
AND r.table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
15
|
+
AND tg.test_suite = '{TEST_SUITE}'
|
|
16
|
+
AND p.run_date::DATE <= '{AS_OF_DATE}'
|
|
17
|
+
GROUP BY r.table_groups_id),
|
|
18
|
+
curprof AS (SELECT p.*
|
|
19
|
+
FROM last_run lr
|
|
20
|
+
INNER JOIN profile_results p
|
|
21
|
+
ON (lr.table_groups_id = p.table_groups_id
|
|
22
|
+
AND lr.last_run_date = p.run_date) ),
|
|
23
|
+
locked AS (SELECT schema_name, table_name, column_name, test_type
|
|
24
|
+
FROM test_definitions
|
|
25
|
+
WHERE table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
26
|
+
AND test_suite = '{TEST_SUITE}'
|
|
27
|
+
AND lock_refresh = 'Y'),
|
|
28
|
+
newtests AS (SELECT project_code, table_groups_id, profile_run_id,
|
|
29
|
+
'Row_Ct' AS test_type,
|
|
30
|
+
'{TEST_SUITE}' AS test_suite,
|
|
31
|
+
'{TEST_SUITE_ID}'::UUID AS test_suite_id,
|
|
32
|
+
schema_name,
|
|
33
|
+
table_name,
|
|
34
|
+
MAX(record_ct) as record_ct
|
|
35
|
+
FROM curprof c
|
|
36
|
+
LEFT JOIN generation_sets s
|
|
37
|
+
ON ('Row_Ct' = s.test_type
|
|
38
|
+
AND '{GENERATION_SET}' = s.generation_set)
|
|
39
|
+
WHERE schema_name = '{DATA_SCHEMA}'
|
|
40
|
+
AND functional_table_type LIKE '%cumulative%'
|
|
41
|
+
AND (s.generation_set IS NOT NULL
|
|
42
|
+
OR '{GENERATION_SET}' = '')
|
|
43
|
+
GROUP BY project_code, table_groups_id, profile_run_id,
|
|
44
|
+
test_type, test_suite, schema_name, table_name )
|
|
45
|
+
SELECT n.project_code, n.table_groups_id, n.profile_run_id,
|
|
46
|
+
n.test_type, n.test_suite, n.test_suite_id,
|
|
47
|
+
n.schema_name, n.table_name,
|
|
48
|
+
0 as skip_errors, record_ct AS threshold_value,
|
|
49
|
+
'{RUN_DATE}'::TIMESTAMP as last_auto_gen_date,
|
|
50
|
+
'Y' as test_active, record_ct as baseline_ct,
|
|
51
|
+
'{AS_OF_DATE}'::TIMESTAMP as profiling_as_of_date
|
|
52
|
+
FROM newtests n
|
|
53
|
+
LEFT JOIN locked l
|
|
54
|
+
ON (n.schema_name = l.schema_name
|
|
55
|
+
AND n.table_name = l.table_name
|
|
56
|
+
AND n.test_type = l.test_type)
|
|
57
|
+
WHERE l.test_type IS NULL;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
-- Insert new tests where a locked test is not already present
|
|
2
|
+
INSERT INTO test_definitions (project_code, table_groups_id, profile_run_id, test_type, test_suite, test_suite_id,
|
|
3
|
+
schema_name, table_name, skip_errors,
|
|
4
|
+
last_auto_gen_date, profiling_as_of_date, test_active,
|
|
5
|
+
baseline_ct, threshold_value)
|
|
6
|
+
WITH last_run AS (SELECT r.table_groups_id, MAX(run_date) AS last_run_date
|
|
7
|
+
FROM profile_results p
|
|
8
|
+
INNER JOIN profiling_runs r
|
|
9
|
+
ON (p.profile_run_id = r.id)
|
|
10
|
+
INNER JOIN test_suites tg
|
|
11
|
+
ON p.project_code = tg.project_code
|
|
12
|
+
AND p.connection_id = tg.connection_id
|
|
13
|
+
WHERE p.project_code = '{PROJECT_CODE}'
|
|
14
|
+
AND r.table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
15
|
+
AND tg.test_suite = '{TEST_SUITE}'
|
|
16
|
+
AND p.run_date::DATE <= '{AS_OF_DATE}'
|
|
17
|
+
GROUP BY r.table_groups_id),
|
|
18
|
+
curprof AS (SELECT p.*
|
|
19
|
+
FROM last_run lr
|
|
20
|
+
INNER JOIN profile_results p
|
|
21
|
+
ON (lr.table_groups_id = p.table_groups_id
|
|
22
|
+
AND lr.last_run_date = p.run_date) ),
|
|
23
|
+
locked AS (SELECT schema_name, table_name, column_name, test_type
|
|
24
|
+
FROM test_definitions
|
|
25
|
+
WHERE table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
26
|
+
AND test_suite = '{TEST_SUITE}'
|
|
27
|
+
AND lock_refresh = 'Y'),
|
|
28
|
+
newtests AS (
|
|
29
|
+
SELECT project_code, table_groups_id, profile_run_id,
|
|
30
|
+
'Row_Ct_Pct' AS test_type,
|
|
31
|
+
'{TEST_SUITE}' AS test_suite,
|
|
32
|
+
'{TEST_SUITE_ID}'::UUID AS test_suite_id,
|
|
33
|
+
schema_name,
|
|
34
|
+
table_name,
|
|
35
|
+
MAX(record_ct) as record_ct
|
|
36
|
+
FROM curprof
|
|
37
|
+
LEFT JOIN generation_sets s
|
|
38
|
+
ON ('Row_Ct_Pct' = s.test_type
|
|
39
|
+
AND '{GENERATION_SET}' = s.generation_set)
|
|
40
|
+
WHERE schema_name = '{DATA_SCHEMA}'
|
|
41
|
+
AND functional_table_type NOT ILIKE '%cumulative%'
|
|
42
|
+
AND (s.generation_set IS NOT NULL
|
|
43
|
+
OR '{GENERATION_SET}' = '')
|
|
44
|
+
GROUP BY project_code, table_groups_id, profile_run_id,
|
|
45
|
+
test_type, test_suite, schema_name, table_name
|
|
46
|
+
HAVING MAX(record_ct) >= 500)
|
|
47
|
+
SELECT n.project_code, n.table_groups_id, n.profile_run_id,
|
|
48
|
+
n.test_type, n.test_suite, n.test_suite_id,
|
|
49
|
+
n.schema_name, n.table_name, 0 as skip_errors,
|
|
50
|
+
'{RUN_DATE}'::TIMESTAMP as last_auto_gen_date,
|
|
51
|
+
'{AS_OF_DATE}'::TIMESTAMP as profiling_as_of_date,
|
|
52
|
+
'Y' as test_active,
|
|
53
|
+
record_ct as baseline_ct, 0.5 AS threshold_value
|
|
54
|
+
FROM newtests n
|
|
55
|
+
LEFT JOIN locked l
|
|
56
|
+
ON (n.schema_name = l.schema_name
|
|
57
|
+
AND n.table_name = l.table_name
|
|
58
|
+
AND n.test_type = l.test_type)
|
|
59
|
+
WHERE l.test_type IS NULL;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
INSERT INTO test_suites
|
|
2
|
+
(project_code, test_suite, connection_id, table_groups_id, test_suite_description,
|
|
3
|
+
component_type, component_key)
|
|
4
|
+
VALUES ('{PROJECT_CODE}', '{TEST_SUITE}', {CONNECTION_ID}, '{TABLE_GROUPS_ID}', '{TEST_SUITE} Test Suite',
|
|
5
|
+
'dataset', '{TEST_SUITE}');
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
WITH existing_rec
|
|
2
|
+
AS ( SELECT tg.project_code, tg.connection_id,
|
|
3
|
+
cc.sql_flavor,
|
|
4
|
+
cc.project_host,
|
|
5
|
+
cc.project_port,
|
|
6
|
+
cc.project_user,
|
|
7
|
+
cc.project_db,
|
|
8
|
+
tg.table_group_schema,
|
|
9
|
+
s.export_to_observability,
|
|
10
|
+
s.test_suite,
|
|
11
|
+
s.id as test_suite_id,
|
|
12
|
+
cc.url,
|
|
13
|
+
cc.connect_by_url,
|
|
14
|
+
CURRENT_TIMESTAMP AT TIME ZONE
|
|
15
|
+
'UTC' - CAST(tg.profiling_delay_days AS INTEGER) * INTERVAL '1 day' AS profiling_as_of_date
|
|
16
|
+
FROM table_groups tg
|
|
17
|
+
INNER JOIN connections cc
|
|
18
|
+
ON (tg.connection_id = cc.connection_id)
|
|
19
|
+
INNER JOIN test_suites s
|
|
20
|
+
ON (tg.id = s.table_groups_id
|
|
21
|
+
AND '{TEST_SUITE}' = s.test_suite)
|
|
22
|
+
WHERE tg.id = '{TABLE_GROUPS_ID}' ),
|
|
23
|
+
new_rec
|
|
24
|
+
AS ( INSERT INTO test_suites
|
|
25
|
+
(project_code, test_suite, connection_id, table_groups_id, test_suite_description,
|
|
26
|
+
component_type, component_key)
|
|
27
|
+
SELECT '{PROJECT_CODE}', '{TEST_SUITE}', {CONNECTION_ID}, '{TABLE_GROUPS_ID}', '{TEST_SUITE} Test Suite',
|
|
28
|
+
'dataset', '{TEST_SUITE}'
|
|
29
|
+
WHERE NOT EXISTS
|
|
30
|
+
(SELECT 1
|
|
31
|
+
FROM test_suites
|
|
32
|
+
WHERE table_groups_id = '{TABLE_GROUPS_ID}'
|
|
33
|
+
AND test_suite = '{TEST_SUITE}')
|
|
34
|
+
RETURNING id as test_suite_id, test_suite, table_groups_id, export_to_observability )
|
|
35
|
+
SELECT project_code, connection_id, sql_flavor,
|
|
36
|
+
project_host, project_port, project_user, project_db, table_group_schema,
|
|
37
|
+
export_to_observability, test_suite, test_suite_id, url, connect_by_url, profiling_as_of_date
|
|
38
|
+
FROM existing_rec
|
|
39
|
+
UNION ALL
|
|
40
|
+
SELECT tg.project_code, tg.connection_id,
|
|
41
|
+
cc.sql_flavor,
|
|
42
|
+
cc.project_host,
|
|
43
|
+
cc.project_port,
|
|
44
|
+
cc.project_user,
|
|
45
|
+
cc.project_db,
|
|
46
|
+
tg.table_group_schema,
|
|
47
|
+
s.export_to_observability,
|
|
48
|
+
s.test_suite,
|
|
49
|
+
s.test_suite_id,
|
|
50
|
+
cc.url,
|
|
51
|
+
cc.connect_by_url,
|
|
52
|
+
CURRENT_TIMESTAMP AT TIME ZONE
|
|
53
|
+
'UTC' - CAST(tg.profiling_delay_days AS INTEGER) * INTERVAL '1 day' AS profiling_as_of_date
|
|
54
|
+
FROM new_rec s
|
|
55
|
+
INNER JOIN table_groups tg
|
|
56
|
+
ON (s.table_groups_id = tg.id)
|
|
57
|
+
INNER JOIN connections cc
|
|
58
|
+
ON (tg.connection_id = cc.connection_id);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
SELECT t.test_type,
|
|
2
|
+
t.selection_criteria,
|
|
3
|
+
t.default_parm_columns,
|
|
4
|
+
t.default_parm_values
|
|
5
|
+
FROM test_types t
|
|
6
|
+
LEFT JOIN generation_sets s
|
|
7
|
+
ON (t.test_type = s.test_type
|
|
8
|
+
AND '{GENERATION_SET}' = s.generation_set)
|
|
9
|
+
WHERE t.active = 'Y'
|
|
10
|
+
AND t.selection_criteria <> 'TEMPLATE' -- Also excludes NULL
|
|
11
|
+
AND (s.generation_set IS NOT NULL
|
|
12
|
+
OR '{GENERATION_SET}' = '')
|
|
13
|
+
ORDER BY test_type;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
-- Insert new tests where a locked test is not already present
|
|
2
|
+
INSERT INTO test_definitions (project_code, table_groups_id, profile_run_id, test_type, test_suite, test_suite_id,
|
|
3
|
+
schema_name, table_name, column_name,
|
|
4
|
+
skip_errors, test_active, last_auto_gen_date, profiling_as_of_date,
|
|
5
|
+
{DEFAULT_PARM_COLUMNS} )
|
|
6
|
+
WITH last_run AS (SELECT r.table_groups_id, MAX(run_date) AS last_run_date
|
|
7
|
+
FROM profile_results p
|
|
8
|
+
INNER JOIN profiling_runs r
|
|
9
|
+
ON (p.profile_run_id = r.id)
|
|
10
|
+
INNER JOIN test_suites tg
|
|
11
|
+
ON p.project_code = tg.project_code
|
|
12
|
+
AND p.connection_id = tg.connection_id
|
|
13
|
+
WHERE p.project_code = '{PROJECT_CODE}'
|
|
14
|
+
AND r.table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
15
|
+
AND tg.test_suite = '{TEST_SUITE}'
|
|
16
|
+
AND p.run_date::DATE <= '{AS_OF_DATE}'
|
|
17
|
+
GROUP BY r.table_groups_id),
|
|
18
|
+
curprof AS (SELECT p.*, datediff('MM', p.min_date, p.max_date) as min_max_months, datediff('week', '1800-01-05'::DATE, p.max_date) - datediff('week', '1800-01-05'::DATE, p.min_date) as min_max_weeks
|
|
19
|
+
FROM last_run lr
|
|
20
|
+
INNER JOIN profile_results p
|
|
21
|
+
ON (lr.table_groups_id = p.table_groups_id
|
|
22
|
+
AND lr.last_run_date = p.run_date) ),
|
|
23
|
+
locked AS (SELECT schema_name, table_name, column_name
|
|
24
|
+
FROM test_definitions
|
|
25
|
+
WHERE table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
26
|
+
AND test_suite = '{TEST_SUITE}'
|
|
27
|
+
AND test_type = '{TEST_TYPE}'
|
|
28
|
+
AND lock_refresh = 'Y'),
|
|
29
|
+
newtests AS (SELECT *
|
|
30
|
+
FROM curprof
|
|
31
|
+
WHERE schema_name = '{DATA_SCHEMA}'
|
|
32
|
+
AND {SELECTION_CRITERIA} )
|
|
33
|
+
SELECT '{PROJECT_CODE}' as project_code,
|
|
34
|
+
'{TABLE_GROUPS_ID}'::UUID as table_groups_id,
|
|
35
|
+
n.profile_run_id,
|
|
36
|
+
'{TEST_TYPE}' AS test_type,
|
|
37
|
+
'{TEST_SUITE}' AS test_suite,
|
|
38
|
+
'{TEST_SUITE_ID}' AS test_suite_id,
|
|
39
|
+
n.schema_name, n.table_name, n.column_name,
|
|
40
|
+
0 as skip_errors, 'Y' as test_active, '{RUN_DATE}'::TIMESTAMP as last_auto_gen_date,
|
|
41
|
+
'{AS_OF_DATE}'::TIMESTAMP as profiling_as_of_date,
|
|
42
|
+
{DEFAULT_PARM_VALUES}
|
|
43
|
+
FROM newtests n
|
|
44
|
+
LEFT JOIN locked l
|
|
45
|
+
ON (n.schema_name = l.schema_name
|
|
46
|
+
AND n.table_name = l.table_name
|
|
47
|
+
AND n.column_name = l.column_name)
|
|
48
|
+
WHERE l.schema_name IS NULL;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
SELECT
|
|
2
|
+
id,
|
|
3
|
+
project_code as project_key,
|
|
4
|
+
connection_id,
|
|
5
|
+
connection_name,
|
|
6
|
+
sql_flavor,
|
|
7
|
+
project_host,
|
|
8
|
+
project_port,
|
|
9
|
+
project_user,
|
|
10
|
+
project_db,
|
|
11
|
+
project_pw_encrypted,
|
|
12
|
+
max_threads,
|
|
13
|
+
max_query_chars,
|
|
14
|
+
project_qc_schema,
|
|
15
|
+
url,
|
|
16
|
+
connect_by_url,
|
|
17
|
+
connect_by_key,
|
|
18
|
+
private_key,
|
|
19
|
+
private_key_passphrase
|
|
20
|
+
FROM connections
|
|
21
|
+
WHERE connection_id = {CONNECTION_ID};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SELECT p.profile_run_id,
|
|
2
|
+
p.run_date,
|
|
3
|
+
p.schema_name,
|
|
4
|
+
p.table_name,
|
|
5
|
+
-- p."position",
|
|
6
|
+
p.column_name,
|
|
7
|
+
p.general_type,
|
|
8
|
+
p.column_type,
|
|
9
|
+
p.datatype_suggestion
|
|
10
|
+
FROM profile_results p
|
|
11
|
+
WHERE profile_run_id = '{PROFILE_RUN_ID}'::UUID
|
|
12
|
+
ORDER BY p.schema_name, p.table_name, p.position;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*profile-info: project-code, connection-id
|
|
2
|
+
Output: latest profiling details
|
|
3
|
+
Optional: run_date (==profiling-run-id==), table-name, column-name, date-from, date-thru*/
|
|
4
|
+
|
|
5
|
+
SELECT profile_run_id,
|
|
6
|
+
run_date,
|
|
7
|
+
schema_name,
|
|
8
|
+
table_name,
|
|
9
|
+
-- position,
|
|
10
|
+
column_name,
|
|
11
|
+
general_type,
|
|
12
|
+
column_type,
|
|
13
|
+
functional_data_type
|
|
14
|
+
FROM profile_results
|
|
15
|
+
WHERE table_name ILIKE '{TABLE_NAME}'
|
|
16
|
+
AND profile_run_id = '{PROFILE_RUN}'::UUID
|
|
17
|
+
ORDER BY table_name, position;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*profile-list: project-code, connection-id
|
|
2
|
+
Output: list of all profiling runs conducted from profiling_runs
|
|
3
|
+
Optional: table-name*/
|
|
4
|
+
|
|
5
|
+
SELECT p.id as profile_run_id,
|
|
6
|
+
p.project_code as project_key,
|
|
7
|
+
schema_name, p.table_groups_id,
|
|
8
|
+
profiling_starttime as start_time, status,
|
|
9
|
+
COUNT(DISTINCT table_name) as tables,
|
|
10
|
+
COUNT(DISTINCT table_name || '.' || column_name) as columns
|
|
11
|
+
FROM profiling_runs p
|
|
12
|
+
INNER JOIN profile_results r
|
|
13
|
+
ON (p.id = r.profile_run_id)
|
|
14
|
+
WHERE p.table_groups_id = '{TABLE_GROUPS_ID}'::UUID
|
|
15
|
+
GROUP BY p.id, p.project_code, p.connection_id, schema_name, p.table_groups_id,
|
|
16
|
+
profiling_starttime, status
|
|
17
|
+
ORDER BY profiling_starttime DESC;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
WITH
|
|
2
|
+
profiling as ( SELECT *
|
|
3
|
+
FROM profile_results
|
|
4
|
+
WHERE profile_run_id = '{PROFILE_RUN}'::UUID
|
|
5
|
+
AND table_name ILIKE '{TABLE_NAME}' ),
|
|
6
|
+
profile_date as (SELECT MAX(run_date) as run_date
|
|
7
|
+
FROM profiling),
|
|
8
|
+
mults AS ( SELECT p.project_code,
|
|
9
|
+
p.table_groups_id,
|
|
10
|
+
p.run_date,
|
|
11
|
+
p.schema_name,
|
|
12
|
+
p.column_name,
|
|
13
|
+
COUNT(*) AS column_ct,
|
|
14
|
+
COUNT(DISTINCT p.column_type) AS type_ct,
|
|
15
|
+
COUNT(DISTINCT p.general_type) AS general_type_ct,
|
|
16
|
+
MIN(p.column_type::TEXT) AS min_type,
|
|
17
|
+
MAX(p.column_type::TEXT) AS max_type,
|
|
18
|
+
MIN(p.distinct_pattern_ct) AS min_pattern_ct,
|
|
19
|
+
MAX(p.distinct_pattern_ct) AS max_pattern_ct,
|
|
20
|
+
SUM(p.distinct_pattern_ct) AS sum_pattern_ct
|
|
21
|
+
FROM profile_results p
|
|
22
|
+
INNER JOIN profile_date d
|
|
23
|
+
ON (p.run_date <= d.run_date)
|
|
24
|
+
GROUP BY p.project_code, p.table_groups_id, p.run_date, p.schema_name, p.column_name
|
|
25
|
+
HAVING COUNT(*) > 1 ),
|
|
26
|
+
results as (SELECT p.schema_name,
|
|
27
|
+
p.table_name,
|
|
28
|
+
p.column_name,
|
|
29
|
+
p.column_type,
|
|
30
|
+
'Suggested Data Type' AS qualification_test,
|
|
31
|
+
p.datatype_suggestion::VARCHAR(200) AS detail
|
|
32
|
+
FROM profiling p
|
|
33
|
+
WHERE LOWER(p.column_type) <> LOWER(p.datatype_suggestion)
|
|
34
|
+
UNION ALL
|
|
35
|
+
SELECT p.schema_name,
|
|
36
|
+
p.table_name,
|
|
37
|
+
p.column_name,
|
|
38
|
+
p.column_type,
|
|
39
|
+
'Non-Standard Blank Values' AS qualification_test,
|
|
40
|
+
(((('Filled Values: ' || p.filled_value_ct::VARCHAR(10)) || ', Null: ') ||
|
|
41
|
+
p.null_value_ct::VARCHAR(10)) || ', Empty String: ') ||
|
|
42
|
+
p.zero_length_ct::VARCHAR(10) AS detail
|
|
43
|
+
FROM profiling p
|
|
44
|
+
WHERE p.filled_value_ct > 0
|
|
45
|
+
OR p.zero_length_ct > 0
|
|
46
|
+
UNION ALL
|
|
47
|
+
SELECT p.schema_name,
|
|
48
|
+
p.table_name,
|
|
49
|
+
p.column_name,
|
|
50
|
+
p.column_type,
|
|
51
|
+
'Invalid Zip Code Format' AS qualification_test,
|
|
52
|
+
(((('Min Length: ' || p.min_length::VARCHAR(10)) || ', Max Length: ') ||
|
|
53
|
+
p.max_length::VARCHAR(10)) || ', Filled Values: ') ||
|
|
54
|
+
p.filled_value_ct::VARCHAR(10) AS detail
|
|
55
|
+
FROM profiling p
|
|
56
|
+
WHERE p.column_name ILIKE '%zip%'
|
|
57
|
+
AND (p.general_type <> 'A' OR p.filled_value_ct > 0 OR p.min_length >= 1 AND p.min_length <= 4 OR
|
|
58
|
+
p.max_length > 10)
|
|
59
|
+
UNION ALL
|
|
60
|
+
SELECT p.schema_name,
|
|
61
|
+
p.table_name,
|
|
62
|
+
p.column_name,
|
|
63
|
+
p.column_type,
|
|
64
|
+
'Multiple Data Types per Column Name: Strict' AS qualification_test,
|
|
65
|
+
(((((('Found ' || m.column_ct::VARCHAR(10)) || ' columns, ') ||
|
|
66
|
+
m.type_ct::VARCHAR(10)) || ' types, ') || m.min_type) || ' to ') ||
|
|
67
|
+
m.max_type AS detail
|
|
68
|
+
FROM profiling p
|
|
69
|
+
INNER JOIN mults m
|
|
70
|
+
ON p.project_code = m.project_code
|
|
71
|
+
AND p.table_groups_id = m.table_groups_id
|
|
72
|
+
AND p.schema_name = m.schema_name
|
|
73
|
+
AND p.column_name = m.column_name
|
|
74
|
+
AND 1 < m.type_ct
|
|
75
|
+
AND 1 = m.general_type_ct
|
|
76
|
+
UNION ALL
|
|
77
|
+
SELECT p.schema_name,
|
|
78
|
+
p.table_name,
|
|
79
|
+
p.column_name,
|
|
80
|
+
p.column_type,
|
|
81
|
+
'Multiple Data Types per Column Name: Loose' AS qualification_test,
|
|
82
|
+
(((((('Found ' || m.column_ct::VARCHAR(10)) || ' columns, ') ||
|
|
83
|
+
m.type_ct::VARCHAR(10)) || ' types, ') || m.min_type) || ' to ') ||
|
|
84
|
+
m.max_type AS detail
|
|
85
|
+
FROM profiling p
|
|
86
|
+
INNER JOIN mults m
|
|
87
|
+
ON p.project_code = m.project_code
|
|
88
|
+
AND p.table_groups_id = m.table_groups_id
|
|
89
|
+
AND p.schema_name = m.schema_name
|
|
90
|
+
AND p.column_name = m.column_name
|
|
91
|
+
AND 1 < m.general_type_ct
|
|
92
|
+
UNION ALL
|
|
93
|
+
SELECT p.schema_name,
|
|
94
|
+
p.table_name,
|
|
95
|
+
p.column_name,
|
|
96
|
+
p.column_type,
|
|
97
|
+
'No column values present' AS qualification_test,
|
|
98
|
+
(((('Null: ' || p.null_value_ct::VARCHAR(10)) || ', Filled: ') ||
|
|
99
|
+
p.filled_value_ct::VARCHAR(10)) || ', Zero Len: ') ||
|
|
100
|
+
p.zero_length_ct::VARCHAR(10) AS detail
|
|
101
|
+
FROM profiling p
|
|
102
|
+
WHERE (p.null_value_ct + p.filled_value_ct + p.zero_length_ct) = p.record_ct
|
|
103
|
+
UNION ALL
|
|
104
|
+
SELECT p.schema_name,
|
|
105
|
+
p.table_name,
|
|
106
|
+
p.column_name,
|
|
107
|
+
p.column_type,
|
|
108
|
+
'Pattern Inconsistency' AS qualification_test,
|
|
109
|
+
'Pattern: ' || p.top_patterns AS detail
|
|
110
|
+
FROM profiling p
|
|
111
|
+
LEFT JOIN mults m
|
|
112
|
+
ON p.project_code = m.project_code
|
|
113
|
+
AND p.table_groups_id = m.table_groups_id
|
|
114
|
+
AND p.schema_name = m.schema_name
|
|
115
|
+
AND p.column_name = m.column_name
|
|
116
|
+
WHERE p.general_type = 'A'
|
|
117
|
+
AND p.max_length > 3
|
|
118
|
+
AND p.value_ct > (p.numeric_ct + p.filled_value_ct)
|
|
119
|
+
AND (p.distinct_pattern_ct < 3 OR m.min_pattern_ct < 3)
|
|
120
|
+
AND (p.distinct_pattern_ct > 1 OR m.sum_pattern_ct > m.column_ct::NUMERIC)
|
|
121
|
+
UNION ALL
|
|
122
|
+
SELECT p.schema_name,
|
|
123
|
+
p.table_name,
|
|
124
|
+
p.column_name,
|
|
125
|
+
p.column_type,
|
|
126
|
+
'Leading Spaces' AS qualification_test,
|
|
127
|
+
'Found: ' || p.lead_space_ct::VARCHAR(10) AS detail
|
|
128
|
+
FROM profiling p
|
|
129
|
+
WHERE p.lead_space_ct > 0
|
|
130
|
+
UNION ALL
|
|
131
|
+
SELECT p.schema_name,
|
|
132
|
+
p.table_name,
|
|
133
|
+
p.column_name,
|
|
134
|
+
p.column_type,
|
|
135
|
+
'Quoted Values' AS qualification_test,
|
|
136
|
+
'Found: ' || p.quoted_value_ct::VARCHAR(10) AS detail
|
|
137
|
+
FROM profiling p
|
|
138
|
+
WHERE quoted_value_ct > 0
|
|
139
|
+
UNION ALL
|
|
140
|
+
SELECT p.schema_name,
|
|
141
|
+
p.table_name,
|
|
142
|
+
p.column_name,
|
|
143
|
+
p.column_type,
|
|
144
|
+
'Mostly Numeric in String' AS qualification_test,
|
|
145
|
+
'Numeric Percent: ' || ROUND(100.0 * p.numeric_ct::NUMERIC(18, 5) / p.value_ct::NUMERIC(18, 5),
|
|
146
|
+
2)::VARCHAR(40) AS detail
|
|
147
|
+
FROM profiling p
|
|
148
|
+
WHERE p.general_type = 'A'
|
|
149
|
+
AND p.column_name NOT ILIKE '%zip'
|
|
150
|
+
AND p.column_name NOT ILIKE '%id'
|
|
151
|
+
AND p.column_name NOT ILIKE '%num'
|
|
152
|
+
AND p.column_name NOT ILIKE '%sk'
|
|
153
|
+
AND p.value_ct > p.numeric_ct
|
|
154
|
+
AND p.numeric_ct::NUMERIC > (0.95 * p.value_ct::NUMERIC)
|
|
155
|
+
UNION ALL
|
|
156
|
+
SELECT p.schema_name,
|
|
157
|
+
p.table_name,
|
|
158
|
+
p.column_name,
|
|
159
|
+
p.column_type,
|
|
160
|
+
'Mostly Dates in String' AS qualification_test,
|
|
161
|
+
'Date Percent: ' ||
|
|
162
|
+
ROUND(100.0 * p.date_ct::NUMERIC(18, 5) / p.value_ct::NUMERIC(18, 5), 2)::VARCHAR(40) AS detail
|
|
163
|
+
FROM profiling p
|
|
164
|
+
WHERE p.general_type = 'A'
|
|
165
|
+
AND p.value_ct > p.date_ct
|
|
166
|
+
AND p.date_ct::NUMERIC > (0.95 * p.value_ct::NUMERIC)
|
|
167
|
+
UNION ALL
|
|
168
|
+
SELECT p.schema_name,
|
|
169
|
+
p.table_name,
|
|
170
|
+
p.column_name,
|
|
171
|
+
p.column_type,
|
|
172
|
+
'Mostly not null, empty or filled values' AS qualification_test,
|
|
173
|
+
(p.record_ct - (p.value_ct - p.zero_length_ct - p.filled_value_ct))::VARCHAR(20) ||
|
|
174
|
+
' of ' || p.record_ct::VARCHAR(20) || ' blank values' AS detail
|
|
175
|
+
FROM profiling p
|
|
176
|
+
WHERE (p.value_ct - p.zero_length_ct - p.filled_value_ct)::FLOAT / p.record_ct::FLOAT > 0.97
|
|
177
|
+
AND (p.value_ct - p.zero_length_ct - p.filled_value_ct) < p.record_ct
|
|
178
|
+
UNION ALL
|
|
179
|
+
SELECT p.schema_name,
|
|
180
|
+
p.table_name,
|
|
181
|
+
p.column_name,
|
|
182
|
+
p.column_type,
|
|
183
|
+
'Mostly one value' AS qualification_test,
|
|
184
|
+
'Freq | Value: ' || top_freq_values AS detail
|
|
185
|
+
FROM profiling p
|
|
186
|
+
WHERE (100.0 * fn_parsefreq(p.top_freq_values, 1, 2)::FLOAT /
|
|
187
|
+
p.value_ct::FLOAT) > 97::FLOAT
|
|
188
|
+
AND (100.0 * fn_parsefreq(p.top_freq_values, 1, 2)::FLOAT /
|
|
189
|
+
p.value_ct::FLOAT) < 100::FLOAT
|
|
190
|
+
UNION ALL
|
|
191
|
+
SELECT p.schema_name,
|
|
192
|
+
p.table_name,
|
|
193
|
+
p.column_name,
|
|
194
|
+
p.column_type,
|
|
195
|
+
'Too many boolean values' AS qualification_test,
|
|
196
|
+
'Top Freq: ' || p.top_freq_values AS detail
|
|
197
|
+
FROM profiling p
|
|
198
|
+
WHERE p.general_type = 'A'
|
|
199
|
+
AND p.distinct_value_ct >= 3
|
|
200
|
+
AND p.distinct_value_ct <= 6
|
|
201
|
+
AND (LOWER(p.top_freq_values) ILIKE '%| true |%' AND
|
|
202
|
+
LOWER(p.top_freq_values) ILIKE '%| false |%' OR
|
|
203
|
+
LOWER(p.top_freq_values) ILIKE '%| yes |&' AND LOWER(p.top_freq_values) ILIKE '%| no |&')
|
|
204
|
+
UNION ALL
|
|
205
|
+
SELECT p.schema_name,
|
|
206
|
+
p.table_name,
|
|
207
|
+
p.column_name,
|
|
208
|
+
p.column_type,
|
|
209
|
+
'Potential Duplicates' AS qualification_test,
|
|
210
|
+
'Top Freq: ' || p.top_freq_values AS detail
|
|
211
|
+
FROM profiling p
|
|
212
|
+
WHERE p.distinct_value_ct > 1000
|
|
213
|
+
AND fn_parsefreq(p.top_freq_values, 1, 2)::BIGINT BETWEEN 2 AND 4
|
|
214
|
+
UNION ALL
|
|
215
|
+
SELECT p.schema_name,
|
|
216
|
+
p.table_name,
|
|
217
|
+
p.column_name,
|
|
218
|
+
p.column_type,
|
|
219
|
+
'Non-Standardized Values in Categories/Codes' AS qualification_test,
|
|
220
|
+
'Distinct Values: ' || p.distinct_value_ct::VARCHAR
|
|
221
|
+
|| ', Standardized: ' || p.distinct_std_value_ct::VARCHAR AS detail
|
|
222
|
+
FROM profiling p
|
|
223
|
+
WHERE p.general_type = 'A'
|
|
224
|
+
AND p.distinct_std_value_ct <> p.distinct_value_ct
|
|
225
|
+
AND p.functional_data_type IN ('Category','Code')
|
|
226
|
+
UNION ALL
|
|
227
|
+
SELECT p.schema_name,
|
|
228
|
+
p.table_name,
|
|
229
|
+
p.column_name,
|
|
230
|
+
p.column_type,
|
|
231
|
+
'Unlikely Date Values out of normal range' AS qualification_test,
|
|
232
|
+
'Date Range: ' || p.min_date::VARCHAR || ' thru ' || p.max_date AS detail
|
|
233
|
+
FROM profiling p
|
|
234
|
+
WHERE p.general_type = 'D'
|
|
235
|
+
AND (p.min_date BETWEEN '0001-01-02'::DATE AND '1900-01-01'::DATE
|
|
236
|
+
OR p.max_date > CURRENT_DATE + INTERVAL '30 year')
|
|
237
|
+
UNION ALL
|
|
238
|
+
SELECT p.schema_name,
|
|
239
|
+
p.table_name,
|
|
240
|
+
'(Table-Wide)' as column_name,
|
|
241
|
+
'' as column_type,
|
|
242
|
+
'Recency - No Table Dates within 1 Year' AS qualification_test,
|
|
243
|
+
'Most Recent Date: ' || MAX(p.max_date)::VARCHAR AS detail
|
|
244
|
+
FROM profiling p
|
|
245
|
+
WHERE p.general_type = 'D'
|
|
246
|
+
GROUP BY p.schema_name, p.table_name
|
|
247
|
+
HAVING MAX(p.max_date) < CURRENT_DATE - INTERVAL '1 year'
|
|
248
|
+
UNION ALL
|
|
249
|
+
SELECT p.schema_name,
|
|
250
|
+
p.table_name,
|
|
251
|
+
p.column_name,
|
|
252
|
+
p.column_type,
|
|
253
|
+
'Unexpected column contains US States' AS qualification_test,
|
|
254
|
+
'Value Range: ' || p.min_text || ' thru ' || max_text AS detail
|
|
255
|
+
FROM profiling p
|
|
256
|
+
WHERE p.std_pattern_match = 'STATE_USA'
|
|
257
|
+
AND p.distinct_value_ct > 5
|
|
258
|
+
AND NOT (p.column_name ILIKE '%state%' OR p.column_name ILIKE '%_st')
|
|
259
|
+
UNION ALL
|
|
260
|
+
SELECT p.schema_name,
|
|
261
|
+
p.table_name,
|
|
262
|
+
p.column_name,
|
|
263
|
+
p.column_type,
|
|
264
|
+
'Unexpected column contains emails' AS qualification_test,
|
|
265
|
+
'Value Range: ' || p.min_text || ' thru ' || max_text AS detail
|
|
266
|
+
FROM v_latest_profile_results p
|
|
267
|
+
WHERE p.table_groups_id = 'a6b876b5-750b-49d3-b4e2-a599eceefe84'::UUID
|
|
268
|
+
AND p.std_pattern_match = 'EMAIL'
|
|
269
|
+
AND NOT (column_name ILIKE '%email%' OR column_name ILIKE '%addr%')
|
|
270
|
+
)
|
|
271
|
+
SELECT table_name, column_name, column_type,
|
|
272
|
+
qualification_test as screening_test, detail
|
|
273
|
+
FROM results
|
|
274
|
+
WHERE qualification_test <> 'Suggested Data Type'
|
|
275
|
+
ORDER BY qualification_test, schema_name, table_name, column_name;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
SELECT
|
|
2
|
+
id as table_group_id,
|
|
3
|
+
project_code as project_key,
|
|
4
|
+
connection_id,
|
|
5
|
+
table_group_schema,
|
|
6
|
+
profiling_table_set,
|
|
7
|
+
profiling_include_mask as include_mask,
|
|
8
|
+
profiling_exclude_mask as exclude_mask
|
|
9
|
+
FROM table_groups
|
|
10
|
+
where project_code = '{PROJECT_CODE}';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*test-generation-list: project-code, test-suite
|
|
2
|
+
Output: list all test generation runs based on last_auto_run_date
|
|
3
|
+
Optional: n/a*/
|
|
4
|
+
|
|
5
|
+
Select test_suite as test_suite_key,
|
|
6
|
+
table_groups_id,
|
|
7
|
+
last_auto_gen_date,
|
|
8
|
+
d.profiling_as_of_date,
|
|
9
|
+
lock_refresh,
|
|
10
|
+
COUNT(DISTINCT schema_name || '.' || table_name) as tables,
|
|
11
|
+
COUNT(DISTINCT schema_name || '.' || table_name || '.' || column_name) as columns,
|
|
12
|
+
COUNT(*) as tests
|
|
13
|
+
from test_definitions d
|
|
14
|
+
where d.project_code = '{PROJECT_CODE}'
|
|
15
|
+
and test_suite = '{TEST_SUITE}'
|
|
16
|
+
and last_auto_gen_date IS NOT NULL
|
|
17
|
+
GROUP BY table_groups_id, project_code, test_suite, last_auto_gen_date, d.profiling_as_of_date, lock_refresh
|
|
18
|
+
order by last_auto_gen_date desc;
|