icsDataValidation 1.0.415__py3-none-any.whl → 1.0.421__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.
- icsDataValidation/core/object_comparison.py +17 -15
- icsDataValidation/main.py +2 -28
- icsDataValidation/output_parameters/result_params.py +7 -7
- icsDataValidation/services/comparison_service.py +33 -14
- icsDataValidation/services/database_services/databricks_hive_metastore_service.py +1 -1
- icsDataValidation/services/database_services/databricks_unity_catalog_service.py +1 -1
- icsDataValidation/services/database_services/oracle_service.py +1 -1
- icsDataValidation/services/database_services/snowflake_service.py +1 -1
- icsDataValidation/services/database_services/sqlserver_service.py +1 -1
- icsDataValidation/services/testset_service.py +57 -22
- icsdatavalidation-1.0.421.dist-info/METADATA +20 -0
- {icsdatavalidation-1.0.415.dist-info → icsdatavalidation-1.0.421.dist-info}/RECORD +14 -14
- icsdatavalidation-1.0.415.dist-info/METADATA +0 -298
- {icsdatavalidation-1.0.415.dist-info → icsdatavalidation-1.0.421.dist-info}/WHEEL +0 -0
- {icsdatavalidation-1.0.415.dist-info → icsdatavalidation-1.0.421.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import time
|
|
3
3
|
|
|
4
|
-
from typing import Union, List, Dict
|
|
4
|
+
from typing import Union, List, Dict
|
|
5
5
|
from threading import current_thread
|
|
6
6
|
from pathlib import PurePath
|
|
7
7
|
|
|
@@ -51,7 +51,7 @@ def get_additional_configuration(src_object: DatabaseObject, testing_tool_params
|
|
|
51
51
|
exclude_columns = additional_configuration[f"{src_object.database}.{src_object.schema}.{src_object.name}"]["EXCLUDE_COLUMNS"]
|
|
52
52
|
exclude_columns = [excluded_column.upper() for excluded_column in exclude_columns]
|
|
53
53
|
logger.info(f"EXCLUDE_COLUMNS: {exclude_columns} ")
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
return src_filter, trgt_filter, exclude_columns
|
|
56
56
|
|
|
57
57
|
def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare: List[Dict]) -> List[Dict]:
|
|
@@ -86,7 +86,7 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
86
86
|
src_filter, trgt_filter, exclude_columns = get_additional_configuration(src_object, testing_tool_params)
|
|
87
87
|
|
|
88
88
|
comparison_service=ComparisonService(src_object, trgt_object, db_service_src, db_service_trgt, src_filter, trgt_filter, exclude_columns, comp_id)
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
#####################################################################
|
|
91
91
|
# execute comparison
|
|
92
92
|
|
|
@@ -99,7 +99,7 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
99
99
|
comparison_service.pandas_dataframe_comparison()
|
|
100
100
|
|
|
101
101
|
#####################################################################
|
|
102
|
-
# TODO as function - check if the object was changed during comparison
|
|
102
|
+
# TODO as function - check if the object was changed during comparison
|
|
103
103
|
|
|
104
104
|
### structure of output needs to be adjusted to enable comparison using > in the if statements
|
|
105
105
|
### florian said the feature is not too important for now, so it's being skipped for now
|
|
@@ -108,7 +108,7 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
108
108
|
# last_altered_trgt = db_service_trgt.get_last_altered_timestamp_from_object(trgt_object)
|
|
109
109
|
|
|
110
110
|
# if comparison_service.result_params.last_altered_src>start_time_utc:
|
|
111
|
-
# comparison_service.result_params.not_altered_during_comparison_src = False
|
|
111
|
+
# comparison_service.result_params.not_altered_during_comparison_src = False
|
|
112
112
|
|
|
113
113
|
# if last_altered_trgt>start_time_utc:
|
|
114
114
|
# comparison_service.result_params.not_altered_during_comparison_trgt = False
|
|
@@ -129,7 +129,7 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
129
129
|
if column_level_comparison_result["DATATYPE_EQUAL"] is False:
|
|
130
130
|
comparison_service.result_params.datatypes_equal = False
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
column_level_comparison_results.append(column_level_comparison_result)
|
|
134
134
|
|
|
135
135
|
#####################################################################
|
|
@@ -151,15 +151,15 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
151
151
|
# prepare and upload live result of the current object
|
|
152
152
|
|
|
153
153
|
live_object_level_comparison_result = ResultService.prepare_object_level_live_result(
|
|
154
|
-
object_level_comparison_result,
|
|
155
|
-
testing_tool_params,
|
|
154
|
+
object_level_comparison_result,
|
|
155
|
+
testing_tool_params,
|
|
156
156
|
)
|
|
157
157
|
|
|
158
158
|
# TODO write as function
|
|
159
159
|
if testing_tool_params.upload_result_to_result_database and not (testing_tool_params.upload_result_to_result_database =='upload_result_to_result_database env variable not found' or testing_tool_params.upload_result_to_result_database =='False'):
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
stage_name = f'{testing_tool_params.result_database_name}.{testing_tool_params.stage_schema}."STG_LIVE_{src_object.schema}_{src_object.name}_{testing_tool_params.run_guid}"'
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
result_file_name = f"{src_object.schema}_{src_object.name}.json"
|
|
164
164
|
|
|
165
165
|
result_file_path = testing_tool_params.live_result_folder_path.joinpath(PurePath(result_file_name))
|
|
@@ -188,7 +188,7 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
188
188
|
else:
|
|
189
189
|
logger.info(f"[{comp_id}] --- Row counts --------> NOT equal")
|
|
190
190
|
logger.info(f"[{comp_id}] Source row count: {comparison_service.result_params.src_row_count}. Target row count: {comparison_service.result_params.trgt_row_count}")
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
if len(comparison_service.result_params.src_columns_upper) != len(set(comparison_service.result_params.src_columns_upper)):
|
|
193
193
|
logger.info(f"[{comp_id}] --- Duplicates in the source column names -> The source system seems to be case sensitive.")
|
|
194
194
|
|
|
@@ -200,13 +200,15 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
200
200
|
else:
|
|
201
201
|
logger.info(f"[{comp_id}] --- Column names ------> NOT equal")
|
|
202
202
|
logger.info(f"[{comp_id}] src_minus_trgt {comparison_service.result_params.src_columns_minus_trgt_columns} and trgt_minus_src {comparison_service.result_params.trgt_columns_minus_src_columns}")
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
if comparison_service.result_params.datatypes_equal:
|
|
205
205
|
logger.info(f"[{comp_id}] --- Data Types --------> EQUAL")
|
|
206
206
|
else:
|
|
207
207
|
logger.info(f"[{comp_id}] --- Data Types --------> NOT equal")
|
|
208
208
|
|
|
209
|
-
if comparison_service.result_params.
|
|
209
|
+
if not comparison_service.result_params.aggregations_compared:
|
|
210
|
+
logger.info(f"[{comp_id}] --- Aggregations ------> NOT compared")
|
|
211
|
+
elif comparison_service.result_params.aggregations_equal:
|
|
210
212
|
logger.info(f"[{comp_id}] --- Aggregations ------> EQUAL")
|
|
211
213
|
else:
|
|
212
214
|
logger.info(f"[{comp_id}] --- Aggregations ------> NOT equal")
|
|
@@ -231,9 +233,9 @@ def compare_objects(testing_tool_params: TestingToolParams, objects_to_compare:
|
|
|
231
233
|
logger.info(f"[{comp_id}] -> src_row_count: {comparison_service.result_params.src_row_count} trgt_row_count:{comparison_service.result_params.trgt_row_count} max_row_number {testing_tool_params.max_row_number}")
|
|
232
234
|
elif comparison_service.result_params.pandas_df_is_equal:
|
|
233
235
|
logger.info(f"[{comp_id}] --- Pandas Dataframes -> EQUAL")
|
|
234
|
-
|
|
236
|
+
|
|
235
237
|
else:
|
|
236
238
|
logger.info(f"[{comp_id}] --- Pandas Dataframes -> NOT equal")
|
|
237
239
|
logger.info('****************************************************')
|
|
238
240
|
|
|
239
|
-
return object_level_comparison_results
|
|
241
|
+
return object_level_comparison_results
|
icsDataValidation/main.py
CHANGED
|
@@ -52,7 +52,7 @@ def execute():
|
|
|
52
52
|
config_file_path, migration_config_file_path = initialization_service.get_config_file_paths()
|
|
53
53
|
|
|
54
54
|
#########################################################################################
|
|
55
|
-
logger.info(f"++++++++++++++++ LOAD
|
|
55
|
+
logger.info(f"++++++++++++++++ LOAD setup_config.json")
|
|
56
56
|
|
|
57
57
|
for configs_key, configs_value in load_json(config_file_path).items():
|
|
58
58
|
setattr(TestingToolParams, configs_key, configs_value)
|
|
@@ -81,38 +81,12 @@ def execute():
|
|
|
81
81
|
logger.info(f"##vso[task.complete result=SucceededWithIssues ;]DONE")
|
|
82
82
|
TestingToolParams.migration_config=None
|
|
83
83
|
|
|
84
|
-
#########################################################################################
|
|
85
|
-
logger.info(f"++++++++++++++++ LOAD testset/whitelist")
|
|
86
|
-
|
|
87
|
-
if testset_file_paths:
|
|
88
|
-
#TODO Error Handling
|
|
89
|
-
try:
|
|
90
|
-
TestingToolParams.testset_whitelist={
|
|
91
|
-
"WHITELIST_OBJECTS_SRC":[],
|
|
92
|
-
"WHITELIST_SCHEMAS_SRC":[],
|
|
93
|
-
"WHITELIST_DATABASES_SRC":[],
|
|
94
|
-
"WHITELIST_OBJECTS_TRGT":[],
|
|
95
|
-
"WHITELIST_SCHEMAS_TRGT":[],
|
|
96
|
-
"WHITELIST_DATABASES_TRGT":[]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
for testset_file_path in testset_file_paths:
|
|
100
|
-
testset_=load_json(testset_file_path)
|
|
101
|
-
for key, value in testset_.items():
|
|
102
|
-
TestingToolParams.testset_whitelist[key]= list(set(TestingToolParams.testset_whitelist[key]) | set(value))
|
|
103
|
-
|
|
104
|
-
except error as e:
|
|
105
|
-
logger.info(f"Not able to load testset from {testset_file_path}.")
|
|
106
|
-
TestingToolParams.testset_whitelist=None
|
|
107
|
-
else:
|
|
108
|
-
TestingToolParams.testset_whitelist=None
|
|
109
|
-
|
|
110
84
|
#########################################################################################
|
|
111
85
|
logger.info(f"++++++++++++++++ INITIALIZE TestsetService")
|
|
112
86
|
|
|
113
87
|
if TestingToolParams.migration_config:
|
|
114
88
|
try:
|
|
115
|
-
testset_service=TestsetService(TestingToolParams.migration_config["MAPPING"],TestingToolParams.migration_config["BLACKLIST"],
|
|
89
|
+
testset_service=TestsetService(TestingToolParams.migration_config["MAPPING"],TestingToolParams.migration_config["BLACKLIST"],testset_file_paths)
|
|
116
90
|
except KeyError as error:
|
|
117
91
|
raise ValueError(f"TestsetService could not be initialized. Check wether the migration_config contains the 'MAPPING' key and the 'BLACKLIST' key. {error}")
|
|
118
92
|
else:
|
|
@@ -44,6 +44,7 @@ class ResultParams():
|
|
|
44
44
|
trgt_columns_aggregate = None
|
|
45
45
|
src_aggregations_error = None
|
|
46
46
|
trgt_aggregations_error = None
|
|
47
|
+
aggregations_compared = None
|
|
47
48
|
aggregation_differences_trgt_minus_src = None
|
|
48
49
|
|
|
49
50
|
# aggregation-comparison (to save)
|
|
@@ -57,7 +58,7 @@ class ResultParams():
|
|
|
57
58
|
# group-by-comparison (to save)
|
|
58
59
|
src_group_by_query = None
|
|
59
60
|
trgt_group_by_query = None
|
|
60
|
-
src_group_by_error = None
|
|
61
|
+
src_group_by_error = None
|
|
61
62
|
trgt_group_by_error = None
|
|
62
63
|
object_group_by_columns = None
|
|
63
64
|
group_by_equal = None
|
|
@@ -68,13 +69,13 @@ class ResultParams():
|
|
|
68
69
|
# sample-check (to save)
|
|
69
70
|
src_sample_query = None
|
|
70
71
|
trgt_sample_query = None
|
|
71
|
-
src_sample_dict = None
|
|
72
|
+
src_sample_dict = None
|
|
72
73
|
trgt_sample_dict = None
|
|
73
74
|
src_sample_error_dict = None
|
|
74
75
|
trgt_sample_error_dict = None
|
|
75
76
|
samples_compared = None
|
|
76
|
-
samples_equal = None
|
|
77
|
-
trgt_key_filters = None
|
|
77
|
+
samples_equal = None
|
|
78
|
+
trgt_key_filters = None
|
|
78
79
|
|
|
79
80
|
# pandas-dataframe-comparison (for further calculation)
|
|
80
81
|
pandas_df_mismatch = None
|
|
@@ -86,9 +87,8 @@ class ResultParams():
|
|
|
86
87
|
pandas_df_compared = None
|
|
87
88
|
pandas_df_is_equal = None
|
|
88
89
|
|
|
89
|
-
# not part of result class:
|
|
90
|
-
# global_iflter
|
|
90
|
+
# not part of result class:
|
|
91
|
+
# global_iflter
|
|
91
92
|
# exclude_columns
|
|
92
93
|
# trgt_key_filters= None
|
|
93
94
|
# additional_configuration_per_table = None
|
|
94
|
-
|
|
@@ -4,7 +4,7 @@ import datetime
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
|
|
6
6
|
from pandas._testing import assert_frame_equal
|
|
7
|
-
from decimal import Decimal
|
|
7
|
+
from decimal import Decimal, InvalidOperation, getcontext
|
|
8
8
|
|
|
9
9
|
from icsDataValidation.utils.logger_util import configure_dev_ops_logger
|
|
10
10
|
from icsDataValidation.utils.pandas_util import get_diff_dataframes, get_diff_dict_from_diff_dataframes
|
|
@@ -44,8 +44,8 @@ class ComparisonService(TestingToolParams):
|
|
|
44
44
|
object_group_by_column=None
|
|
45
45
|
for object_group_by_column in group_by_column_candidates:
|
|
46
46
|
|
|
47
|
-
src_group_by_column_count_distinct=next(item["COUNT_DISTINCT"] for item in src_column_count_distincts if item["COLUMN_NAME"].upper() == object_group_by_column)
|
|
48
|
-
trgt_group_by_column_count_distinct=next(item["COUNT_DISTINCT"] for item in trgt_column_count_distincts if item["COLUMN_NAME"].upper() == object_group_by_column)
|
|
47
|
+
src_group_by_column_count_distinct=next((item["COUNT_DISTINCT"] for item in src_column_count_distincts if item["COLUMN_NAME"].upper() == object_group_by_column), None)
|
|
48
|
+
trgt_group_by_column_count_distinct=next((item["COUNT_DISTINCT"] for item in trgt_column_count_distincts if item["COLUMN_NAME"].upper() == object_group_by_column), None)
|
|
49
49
|
|
|
50
50
|
if (trgt_group_by_column_count_distinct<=1 or src_group_by_column_count_distinct<=1):
|
|
51
51
|
logger.info(f"[{self.comp_id}] The GROUP_BY_COLUMN {object_group_by_column} does not satisfy the necessary criteria.")
|
|
@@ -166,16 +166,31 @@ class ComparisonService(TestingToolParams):
|
|
|
166
166
|
del trgt_columns_aggregate['TESTATM_ERRORS']
|
|
167
167
|
|
|
168
168
|
if self.result_params.src_row_count != 0 and self.result_params.trgt_row_count != 0:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
try:
|
|
170
|
+
aggregation_differences_trgt_minus_src_not_boolean = {
|
|
171
|
+
k: round(Decimal(trgt_columns_aggregate[k][1])
|
|
172
|
+
- Decimal(src_columns_aggregate[k][1]), self.numeric_scale)
|
|
173
|
+
for k in src_columns_aggregate.keys()
|
|
174
|
+
if k in trgt_columns_aggregate
|
|
175
|
+
and str(src_columns_aggregate[k][1]) != str(trgt_columns_aggregate[k][1])
|
|
176
|
+
and src_columns_aggregate[k][1] != trgt_columns_aggregate[k][1]
|
|
177
|
+
and src_columns_aggregate[k][0].upper() != 'AGGREGATEBOOLEAN'
|
|
178
|
+
and trgt_columns_aggregate[k][0].upper() != 'AGGREGATEBOOLEAN'
|
|
179
|
+
}
|
|
180
|
+
except InvalidOperation as e:
|
|
181
|
+
getcontext().prec = 100 # sets the precision of Decimal to a higher value - due to the limitations of the decimal module when handling such large numbers with high precision
|
|
182
|
+
aggregation_differences_trgt_minus_src_not_boolean = {
|
|
183
|
+
k: round(Decimal(trgt_columns_aggregate[k][1])
|
|
184
|
+
- Decimal(src_columns_aggregate[k][1]), self.numeric_scale)
|
|
185
|
+
for k in src_columns_aggregate.keys()
|
|
186
|
+
if k in trgt_columns_aggregate
|
|
187
|
+
and str(src_columns_aggregate[k][1]) != str(trgt_columns_aggregate[k][1])
|
|
188
|
+
and src_columns_aggregate[k][1] != trgt_columns_aggregate[k][1]
|
|
189
|
+
and src_columns_aggregate[k][0].upper() != 'AGGREGATEBOOLEAN'
|
|
190
|
+
and trgt_columns_aggregate[k][0].upper() != 'AGGREGATEBOOLEAN'
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
179
194
|
aggregation_differences_trgt_minus_src_boolean = {
|
|
180
195
|
k: str(
|
|
181
196
|
int(trgt_columns_aggregate[k][1].split('_',1)[0])
|
|
@@ -233,9 +248,11 @@ class ComparisonService(TestingToolParams):
|
|
|
233
248
|
else:
|
|
234
249
|
aggregation_differences_trgt_minus_src = {}
|
|
235
250
|
|
|
251
|
+
aggregations_compared = True
|
|
236
252
|
aggregations_equal = True
|
|
237
253
|
if src_aggregations_error or trgt_aggregations_error:
|
|
238
254
|
aggregations_equal = None
|
|
255
|
+
aggregations_compared = False
|
|
239
256
|
else:
|
|
240
257
|
for aggregation_diff in aggregation_differences_trgt_minus_src.values():
|
|
241
258
|
if aggregation_diff and not aggregation_diff == 0.0:
|
|
@@ -252,6 +269,7 @@ class ComparisonService(TestingToolParams):
|
|
|
252
269
|
self.result_params.aggregation_differences_trgt_minus_src = aggregation_differences_trgt_minus_src
|
|
253
270
|
self.result_params.src_error_dict = src_error_dict
|
|
254
271
|
self.result_params.trgt_error_dict = trgt_error_dict
|
|
272
|
+
self.result_params.aggregations_compared = aggregations_compared
|
|
255
273
|
self.result_params.aggregations_equal = aggregations_equal
|
|
256
274
|
|
|
257
275
|
|
|
@@ -572,7 +590,8 @@ class ComparisonService(TestingToolParams):
|
|
|
572
590
|
samples_equal = True
|
|
573
591
|
except:
|
|
574
592
|
samples_equal = False
|
|
575
|
-
|
|
593
|
+
else:
|
|
594
|
+
samples_compared = False
|
|
576
595
|
# save results
|
|
577
596
|
self.result_params.src_sample_query = src_sample_query
|
|
578
597
|
self.result_params.trgt_sample_query = trgt_sample_query
|
|
@@ -371,7 +371,7 @@ class DatabricksHiveMetastoreService(object):
|
|
|
371
371
|
|
|
372
372
|
except Exception as err:
|
|
373
373
|
# raise err
|
|
374
|
-
dict_count_distincts = [
|
|
374
|
+
dict_count_distincts = []
|
|
375
375
|
error_list.append(
|
|
376
376
|
["ERROR", str(err).split("|||")[0], str(err).split("|||")[1]]
|
|
377
377
|
)
|
|
@@ -369,7 +369,7 @@ class DatabricksUnityCatalogService(object):
|
|
|
369
369
|
|
|
370
370
|
except Exception as err:
|
|
371
371
|
# raise err
|
|
372
|
-
dict_count_distincts = [
|
|
372
|
+
dict_count_distincts = []
|
|
373
373
|
error_list.append(
|
|
374
374
|
["ERROR", str(err).split("|||")[0], str(err).split("|||")[1]]
|
|
375
375
|
)
|
|
@@ -334,7 +334,7 @@ class SnowflakeService:
|
|
|
334
334
|
|
|
335
335
|
except Exception as err:
|
|
336
336
|
# raise err
|
|
337
|
-
dict_count_distincts = [
|
|
337
|
+
dict_count_distincts = []
|
|
338
338
|
error_list.append(["ERROR", str(err).split("|||")[0], str(err).split("|||")[1]])
|
|
339
339
|
|
|
340
340
|
return dict_count_distincts, error_list
|
|
@@ -387,7 +387,7 @@ class SQLServerService:
|
|
|
387
387
|
try:
|
|
388
388
|
dict_count_distincts = self.execute_queries(query_get_count_distincts_from_object)
|
|
389
389
|
except Exception as err:
|
|
390
|
-
dict_count_distincts = [
|
|
390
|
+
dict_count_distincts = []
|
|
391
391
|
error_list.append(["ERROR", str(err).split("|||")[0], str(err).split("|||")[1]])
|
|
392
392
|
|
|
393
393
|
return dict_count_distincts, error_list
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
from icsDataValidation.utils.file_util import load_json
|
|
3
4
|
from icsDataValidation.utils.logger_util import configure_dev_ops_logger
|
|
4
5
|
|
|
5
6
|
#########################################################################################
|
|
@@ -19,14 +20,48 @@ class TestsetService:
|
|
|
19
20
|
Handles blacklists and whitelists.
|
|
20
21
|
"""
|
|
21
22
|
|
|
22
|
-
def __init__(self, testset_mapping:dict, testset_blacklist: dict,
|
|
23
|
+
def __init__(self, testset_mapping:dict, testset_blacklist: dict, testset_file_paths: list=None):
|
|
23
24
|
self.testset_mapping = testset_mapping
|
|
24
25
|
self.testset_blacklist = testset_blacklist
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
if testset_file_paths:
|
|
28
|
+
self.testset_whitelist = self._load_testset(testset_file_paths)
|
|
29
|
+
else:
|
|
30
|
+
self.testset_whitelist = None
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def _load_testset(testset_file_paths):
|
|
34
|
+
"""
|
|
35
|
+
Load the testset files from a list of file paths.
|
|
36
|
+
Configure the whitelist of databases, schemas, and objects.
|
|
37
|
+
"""
|
|
38
|
+
logger.info(f"++++++++++++++++ LOAD testset/whitelist")
|
|
39
|
+
try:
|
|
40
|
+
testset_whitelist={
|
|
41
|
+
"WHITELIST_OBJECTS_SRC":[],
|
|
42
|
+
"WHITELIST_SCHEMAS_SRC":[],
|
|
43
|
+
"WHITELIST_DATABASES_SRC":[],
|
|
44
|
+
"WHITELIST_OBJECTS_TRGT":[],
|
|
45
|
+
"WHITELIST_SCHEMAS_TRGT":[],
|
|
46
|
+
"WHITELIST_DATABASES_TRGT":[]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for testset_file_path in testset_file_paths:
|
|
50
|
+
testset_=load_json(testset_file_path)
|
|
51
|
+
for key, value in testset_.items():
|
|
52
|
+
testset_whitelist[key]= list(set(testset_whitelist[key]) | set(value))
|
|
53
|
+
except FileNotFoundError as file_not_found_err:
|
|
54
|
+
logger.error(f"Not able to load testset from {testset_file_path}!")
|
|
55
|
+
raise file_not_found_err
|
|
56
|
+
except Exception as exc:
|
|
57
|
+
logger.error("Unexpected exception while trying to load testset and/or defining the whitelist:\n", exc_info=exc)
|
|
58
|
+
raise exc
|
|
59
|
+
|
|
60
|
+
return testset_whitelist
|
|
26
61
|
|
|
27
62
|
def handle_database_mapping(self, source_database_name: str = None) -> str:
|
|
28
63
|
"""
|
|
29
|
-
Map the source and the target database.
|
|
64
|
+
Map the source and the target database.
|
|
30
65
|
Note: Case-Insensitive and returns upper-case target database name.
|
|
31
66
|
"""
|
|
32
67
|
target_database_name=source_database_name.upper()
|
|
@@ -40,7 +75,7 @@ class TestsetService:
|
|
|
40
75
|
|
|
41
76
|
def handle_schema_mapping(self, source_schema_name: str = None, source_database_name: str = None) -> str:
|
|
42
77
|
"""
|
|
43
|
-
Map the source and the target schema.
|
|
78
|
+
Map the source and the target schema.
|
|
44
79
|
Note: Case-Insensitive and returns upper-case target schema name.
|
|
45
80
|
"""
|
|
46
81
|
target_schema_name=source_schema_name.upper()
|
|
@@ -48,7 +83,7 @@ class TestsetService:
|
|
|
48
83
|
|
|
49
84
|
if self.testset_mapping and "SCHEMA_MAPPING" in self.testset_mapping:
|
|
50
85
|
for schema_mapping in self.testset_mapping["SCHEMA_MAPPING"]:
|
|
51
|
-
|
|
86
|
+
|
|
52
87
|
if f"{source_database_name.upper()}.{source_schema_name.upper()}" == schema_mapping["src_schema_identifier"].upper():
|
|
53
88
|
target_schema_name = schema_mapping["trgt_schema_name"].upper()
|
|
54
89
|
found_schema_mapping = True
|
|
@@ -72,7 +107,7 @@ class TestsetService:
|
|
|
72
107
|
target_schema_name=source_schema_name.upper()
|
|
73
108
|
|
|
74
109
|
return target_schema_name
|
|
75
|
-
|
|
110
|
+
|
|
76
111
|
def handle_blacklist(self, database_objects: dict, src_trgt: str)-> dict:
|
|
77
112
|
"""
|
|
78
113
|
Handle the blacklist from the migration_config to restrict database objects.
|
|
@@ -95,7 +130,7 @@ class TestsetService:
|
|
|
95
130
|
database_objects.remove(db_object)
|
|
96
131
|
|
|
97
132
|
return database_objects
|
|
98
|
-
|
|
133
|
+
|
|
99
134
|
def handle_whitelist(self, database_objects: dict, src_trgt: str)-> dict:
|
|
100
135
|
"""
|
|
101
136
|
Handle the whitelist which is defined as a testset to restrict database objects.
|
|
@@ -114,7 +149,7 @@ class TestsetService:
|
|
|
114
149
|
database_objects.remove(db_object)
|
|
115
150
|
|
|
116
151
|
return database_objects
|
|
117
|
-
|
|
152
|
+
|
|
118
153
|
def map_objects(self, database_objects_src: list, database_objects_trgt: list):
|
|
119
154
|
"""
|
|
120
155
|
Maps objects between source and target by using the mapping defined in the migration_config.json.
|
|
@@ -130,10 +165,10 @@ class TestsetService:
|
|
|
130
165
|
|
|
131
166
|
trgt_objects_minus_src_table_identifiers = [object["object_identifier"] for object in database_objects_trgt if object not in database_objects_src and object["object_type"] == 'table']
|
|
132
167
|
trgt_objects_minus_src_view_identifiers = [object["object_identifier"] for object in database_objects_trgt if object not in database_objects_src and object["object_type"] == 'view']
|
|
133
|
-
|
|
168
|
+
|
|
134
169
|
|
|
135
170
|
if database_objects_src != database_objects_trgt and self.testset_mapping:
|
|
136
|
-
|
|
171
|
+
|
|
137
172
|
src_objects_minus_trgt_objects_ = src_objects_minus_trgt_objects.copy()
|
|
138
173
|
|
|
139
174
|
trgt_objects_minus_src_object_identifiers=[object["object_identifier"] for object in trgt_objects_minus_src_objects]
|
|
@@ -145,10 +180,10 @@ class TestsetService:
|
|
|
145
180
|
#########################################################################################
|
|
146
181
|
# Object-Mapping
|
|
147
182
|
for mapping in self.testset_mapping["OBJECT_MAPPING"]:
|
|
148
|
-
|
|
183
|
+
|
|
149
184
|
if (
|
|
150
|
-
db_object["object_identifier"] == mapping["src_object_identifier"].upper()
|
|
151
|
-
and db_object["object_type"] == mapping["src_object_type"]
|
|
185
|
+
db_object["object_identifier"] == mapping["src_object_identifier"].upper()
|
|
186
|
+
and db_object["object_type"] == mapping["src_object_type"]
|
|
152
187
|
and mapping['trgt_object_identifier'].upper() in trgt_objects_minus_src_object_identifiers
|
|
153
188
|
):
|
|
154
189
|
logger.info(f" -> mapping object found: {mapping}")
|
|
@@ -159,8 +194,8 @@ class TestsetService:
|
|
|
159
194
|
if trgt_object["object_identifier"] == mapping["trgt_object_identifier"].upper():
|
|
160
195
|
trgt_objects_minus_src_objects.remove(trgt_object)
|
|
161
196
|
logger.info(" -> added by 1:1 mapping")
|
|
162
|
-
|
|
163
|
-
# set continue_flag to false because this object has been covered by the mapping
|
|
197
|
+
|
|
198
|
+
# set continue_flag to false because this object has been covered by the mapping
|
|
164
199
|
continue_flag = False
|
|
165
200
|
break
|
|
166
201
|
|
|
@@ -168,7 +203,7 @@ class TestsetService:
|
|
|
168
203
|
# Database-Mapping, and Schema-Mapping
|
|
169
204
|
|
|
170
205
|
if continue_flag == True:
|
|
171
|
-
|
|
206
|
+
|
|
172
207
|
src_database_name = db_object["object_identifier"].split(".",1)[0]
|
|
173
208
|
src_schema_name = db_object["object_identifier"].split(".",2)[1]
|
|
174
209
|
src_object_name = db_object["object_identifier"].split(".",2)[2]
|
|
@@ -181,21 +216,21 @@ class TestsetService:
|
|
|
181
216
|
if (db_object["object_type"] == 'table' and trgt_object_identifier in trgt_objects_minus_src_table_identifiers) or (db_object["object_type"] == 'view' and trgt_object_identifier in trgt_objects_minus_src_view_identifiers):
|
|
182
217
|
intersection_objects_mapped_trgt_src.append({"src_object_identifier": db_object["object_identifier"],"src_object_type": db_object["object_type"], "trgt_object_identifier": trgt_object_identifier,"trgt_object_type": db_object["object_type"]})
|
|
183
218
|
src_objects_minus_trgt_objects.remove(db_object)
|
|
184
|
-
|
|
219
|
+
|
|
185
220
|
for trgt_object in trgt_objects_minus_src_objects:
|
|
186
221
|
if trgt_object["object_identifier"] == trgt_object_identifier:
|
|
187
222
|
trgt_objects_minus_src_objects.remove(trgt_object)
|
|
188
223
|
|
|
189
224
|
logger.info(" -> added by database/schema-mapping")
|
|
190
225
|
|
|
191
|
-
# set continue_flag to false because this object has been covered by the replacements
|
|
226
|
+
# set continue_flag to false because this object has been covered by the replacements
|
|
192
227
|
continue_flag = False
|
|
193
228
|
|
|
194
229
|
##########################################################################################
|
|
195
230
|
# Replace-Mapping
|
|
196
231
|
|
|
197
232
|
if continue_flag == True:
|
|
198
|
-
|
|
233
|
+
|
|
199
234
|
|
|
200
235
|
src_database_name = db_object["object_identifier"].split(".",1)[0]
|
|
201
236
|
src_schema_name = db_object["object_identifier"].split(".",2)[1]
|
|
@@ -217,7 +252,7 @@ class TestsetService:
|
|
|
217
252
|
# trgt_objects_minus_src_objects.remove(trgt_object)
|
|
218
253
|
# logger.info(" -> added by replace mapping")
|
|
219
254
|
#
|
|
220
|
-
# # set continue_flag to false because this object has been covered by the replacements
|
|
255
|
+
# # set continue_flag to false because this object has been covered by the replacements
|
|
221
256
|
# continue_flag = False
|
|
222
257
|
# break
|
|
223
258
|
|
|
@@ -243,7 +278,7 @@ class TestsetService:
|
|
|
243
278
|
all_objects_matching=False
|
|
244
279
|
|
|
245
280
|
return intersection_objects_mapped_trgt_src, object_identifiers_src_minus_trgt, object_identifiers_trgt_minus_src, remaining_mapping_objects, all_objects_matching
|
|
246
|
-
|
|
281
|
+
|
|
247
282
|
@staticmethod
|
|
248
283
|
def get_intersection_objects_trgt_src(database_objects_src: list, database_objects_trgt: list, intersection_objects_mapped_trgt_src:list):
|
|
249
284
|
"""
|
|
@@ -253,5 +288,5 @@ class TestsetService:
|
|
|
253
288
|
intersection_objects_trgt_src_without_mapping =[{"src_object_identifier": object["object_identifier"],"src_object_type": object["object_type"],"trgt_object_identifier": object["object_identifier"],"trgt_object_type": object["object_type"]} for object in database_objects_src if object in database_objects_trgt]
|
|
254
289
|
|
|
255
290
|
intersection_objects_trgt_src= intersection_objects_trgt_src_without_mapping + intersection_objects_mapped_trgt_src
|
|
256
|
-
|
|
291
|
+
|
|
257
292
|
return intersection_objects_trgt_src
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: icsDataValidation
|
|
3
|
+
Version: 1.0.421
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author-email: initions <ICSMC_EXT_PYPIORG@accenture.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: azure-storage-blob==12.13.1
|
|
10
|
+
Requires-Dist: boto3==1.26.154
|
|
11
|
+
Requires-Dist: cloe-util-snowflake-connector==1.0.5
|
|
12
|
+
Requires-Dist: databricks-sdk==0.29.0
|
|
13
|
+
Requires-Dist: databricks-sql-connector==3.0.1
|
|
14
|
+
Requires-Dist: numpy==1.26.3
|
|
15
|
+
Requires-Dist: oracledb==2.5.0
|
|
16
|
+
Requires-Dist: pandas==2.2.2
|
|
17
|
+
Requires-Dist: pyexasol==0.24.0
|
|
18
|
+
Requires-Dist: pyodbc
|
|
19
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
20
|
+
Requires-Dist: teradatasql==17.20.0.10
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
icsDataValidation/configuration.py,sha256=HOFjmC8_e2nvoItndMtJQQA1MR5aCgZGeF1AwY_FvjE,477
|
|
2
|
-
icsDataValidation/main.py,sha256=
|
|
2
|
+
icsDataValidation/main.py,sha256=1CtzUa0-LALTH9i5eQ6H6PW0UON3TPHZ5ey9qDsljKQ,11502
|
|
3
3
|
icsDataValidation/connection_setups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
icsDataValidation/connection_setups/azure_connection_setup.py,sha256=qxPvD-VZhdJqrdj06IVIk2Ud287YlLhE22Q5_oYKetM,790
|
|
5
5
|
icsDataValidation/connection_setups/databricks_connection_setup.py,sha256=dNEBum-8R-TUW2SCEk3CaNtCr_gLFvn456KBlENpgJU,1220
|
|
@@ -10,25 +10,25 @@ icsDataValidation/connection_setups/sqlserver_connection_setup.py,sha256=ayRao5B
|
|
|
10
10
|
icsDataValidation/connection_setups/teradata_connection_setup.py,sha256=fIpuxz-FTqFK2vSMSuokqU9sdJkaJ4UP5piY_zIbj5k,624
|
|
11
11
|
icsDataValidation/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
icsDataValidation/core/database_objects.py,sha256=2oaDaVQajSYI_HJjJy1pmc6FsoK_wMfwgu6ZgEcFvow,523
|
|
13
|
-
icsDataValidation/core/object_comparison.py,sha256=
|
|
13
|
+
icsDataValidation/core/object_comparison.py,sha256=xJvgHdoRaMzFMQishpzEszO7bW31Ll9BUCsyzqwrRVs,15045
|
|
14
14
|
icsDataValidation/input_parameters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
icsDataValidation/input_parameters/testing_tool_params.py,sha256=trVZmxd2hsJRBWgdv0YePdaA9T20QbL3bOCVUOwIH18,6907
|
|
16
16
|
icsDataValidation/output_parameters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
icsDataValidation/output_parameters/result_params.py,sha256=
|
|
17
|
+
icsDataValidation/output_parameters/result_params.py,sha256=HLS7DUX8NWWw3j5de8qOQ4T4auWbyMuwmuafzaBOjnU,2861
|
|
18
18
|
icsDataValidation/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
icsDataValidation/services/comparison_service.py,sha256=
|
|
19
|
+
icsDataValidation/services/comparison_service.py,sha256=6ponyBGgXRrVQyX2aYUpHlIbEMhUtWKS8N3KYSWAjEw,45176
|
|
20
20
|
icsDataValidation/services/initialization_service.py,sha256=AHbJrq_LjMPFoeOJC2pi2ZZ1xkL8njSZn38psc3do60,6687
|
|
21
21
|
icsDataValidation/services/result_service.py,sha256=edD6aejIi5P7qDNHKnN46KrN5tfzwqnw5TB35SvFAWU,28396
|
|
22
22
|
icsDataValidation/services/system_service.py,sha256=GErl_Zx_DaajXTTyfJJ5_xqpd2nLnfnRHcPDa_OVF58,3518
|
|
23
|
-
icsDataValidation/services/testset_service.py,sha256=
|
|
23
|
+
icsDataValidation/services/testset_service.py,sha256=HKD1xgq-SdwlkXu5FDd6pgeCp8Pkbm14GTzwbGIrBtk,16616
|
|
24
24
|
icsDataValidation/services/database_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
icsDataValidation/services/database_services/azure_service.py,sha256=bAfpekHowj92qAm3C0hVyxwTpg5J3DoF82DdGKXoe6Q,16932
|
|
26
|
-
icsDataValidation/services/database_services/databricks_hive_metastore_service.py,sha256=
|
|
27
|
-
icsDataValidation/services/database_services/databricks_unity_catalog_service.py,sha256=
|
|
26
|
+
icsDataValidation/services/database_services/databricks_hive_metastore_service.py,sha256=HLdv4YakTJB669iVsaKvs0-FbpiJ3hkk27oca-EpJhQ,88156
|
|
27
|
+
icsDataValidation/services/database_services/databricks_unity_catalog_service.py,sha256=8iV75kvtQsGPdC35m89jO5s0ZQDekPdRVPYGbdCAPVI,70835
|
|
28
28
|
icsDataValidation/services/database_services/exasol_service.py,sha256=LdjU8mM77zTmNmhJPQrgQO-HwAZv0C0seYMDjuWU9BQ,11153
|
|
29
|
-
icsDataValidation/services/database_services/oracle_service.py,sha256=
|
|
30
|
-
icsDataValidation/services/database_services/snowflake_service.py,sha256=
|
|
31
|
-
icsDataValidation/services/database_services/sqlserver_service.py,sha256=
|
|
29
|
+
icsDataValidation/services/database_services/oracle_service.py,sha256=Ejxi0HBRF_c0xWY4wEsw8L8Rb5FMRf9cjQbhz8kerIA,31805
|
|
30
|
+
icsDataValidation/services/database_services/snowflake_service.py,sha256=7Jkyr4eNk7HnVc2ju5XhcW-g0R9SnOnusyf7-Hpj6t8,63416
|
|
31
|
+
icsDataValidation/services/database_services/sqlserver_service.py,sha256=tT42aCxIJ8g6Qr5UsI4cQM_YYeXt-QolKSeVm_hSBKY,38455
|
|
32
32
|
icsDataValidation/services/database_services/teradata_service.py,sha256=h1UX-Wrf9qvZ_hXpH-Y63TRZ8csOCVcEjFn6ux7hvyk,40299
|
|
33
33
|
icsDataValidation/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
icsDataValidation/utils/file_util.py,sha256=ZTMB1sTnIIdffg9tEJRCFQQ5SG8Fksc5ie1PM4gHXG4,3432
|
|
@@ -36,7 +36,7 @@ icsDataValidation/utils/logger_util.py,sha256=xS48_FFMot_hyQgJY8DUeRTn5jpdvRt5QI
|
|
|
36
36
|
icsDataValidation/utils/pandas_util.py,sha256=D_g7Xw7BIS2E-1ZhJIvp62K5xuKjIkj-7TxH4HN_8SI,6505
|
|
37
37
|
icsDataValidation/utils/parallelization_util.py,sha256=6P0YcQLmunW_fHR4f5-kdncZbOlxxqKyk6ZAFQQEd2k,2088
|
|
38
38
|
icsDataValidation/utils/sql_util.py,sha256=0c-BInElSsRmXUedfLP_h9Wsiscv9aic7IIc5f15Uzo,396
|
|
39
|
-
icsdatavalidation-1.0.
|
|
40
|
-
icsdatavalidation-1.0.
|
|
41
|
-
icsdatavalidation-1.0.
|
|
42
|
-
icsdatavalidation-1.0.
|
|
39
|
+
icsdatavalidation-1.0.421.dist-info/METADATA,sha256=irZyTjWSOKvsU_IT8inVhRYnWnj0Xc0__S95shkxyrQ,661
|
|
40
|
+
icsdatavalidation-1.0.421.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
41
|
+
icsdatavalidation-1.0.421.dist-info/top_level.txt,sha256=BqWUGJb4J7ZybpDMeuGHxEHGHwXXJEIURd9pBybHzTM,18
|
|
42
|
+
icsdatavalidation-1.0.421.dist-info/RECORD,,
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: icsDataValidation
|
|
3
|
-
Version: 1.0.415
|
|
4
|
-
Summary: Add your description here
|
|
5
|
-
Author-email: initions <ICSMC_EXT_PYPIORG@accenture.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Requires-Python: >=3.11
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
Requires-Dist: azure-storage-blob==12.13.1
|
|
10
|
-
Requires-Dist: boto3==1.26.154
|
|
11
|
-
Requires-Dist: cloe-util-snowflake-connector==1.0.5
|
|
12
|
-
Requires-Dist: databricks-sdk==0.29.0
|
|
13
|
-
Requires-Dist: databricks-sql-connector==3.0.1
|
|
14
|
-
Requires-Dist: numpy==1.26.3
|
|
15
|
-
Requires-Dist: oracledb==2.5.0
|
|
16
|
-
Requires-Dist: pandas==2.2.2
|
|
17
|
-
Requires-Dist: pyexasol==0.24.0
|
|
18
|
-
Requires-Dist: pyodbc
|
|
19
|
-
Requires-Dist: python-dotenv>=1.0.1
|
|
20
|
-
Requires-Dist: teradatasql==17.20.0.10
|
|
21
|
-
|
|
22
|
-
# icsDV - initions Data Validation Tool
|
|
23
|
-
|
|
24
|
-
## Introduction
|
|
25
|
-
|
|
26
|
-
The icsDataValidation tool identifies data mismatches between two databases.
|
|
27
|
-
The functionalities are specifically geared to support migration projects.
|
|
28
|
-
It helps to find data issues in tables and views in comparison of a source and a target system.
|
|
29
|
-
|
|
30
|
-
### What is "generic" about the tool?
|
|
31
|
-
|
|
32
|
-
The icsDataValidation tool (icsDV) is in particular structered in a way that it is easily expandable.
|
|
33
|
-
The main code is used by all different database options.
|
|
34
|
-
Specifics for each supported database are implemented in a database service per database.
|
|
35
|
-
|
|
36
|
-
The different database services are very similar.
|
|
37
|
-
They hold the same methods with the same input and output parameters.
|
|
38
|
-
Each method is aligned with the syntax and the settings of the database it is created for.
|
|
39
|
-
Each core implementation includes connections setup, object comparison functionality and the result preparation.
|
|
40
|
-
|
|
41
|
-
### Supported Databases
|
|
42
|
-
|
|
43
|
-
The icsDV supports comparisons between the following databases:
|
|
44
|
-
|
|
45
|
-
- Snowflake
|
|
46
|
-
- Teradata
|
|
47
|
-
- Azure SQL Server
|
|
48
|
-
- Exasol
|
|
49
|
-
- Oracle
|
|
50
|
-
- Databricks with and without Unity Catalog
|
|
51
|
-
|
|
52
|
-
Comparison results can be written to either Snowflake or Databricks.
|
|
53
|
-
|
|
54
|
-
### Features
|
|
55
|
-
|
|
56
|
-
The key features of the tool are:
|
|
57
|
-
|
|
58
|
-
- Comparison of tables and views between a source and a target system.
|
|
59
|
-
- Pipeline integration in Azure DevOps or GitLab
|
|
60
|
-
- Multiple verification/comparison steps:
|
|
61
|
-
- Row count comparison
|
|
62
|
-
- Column names comparison
|
|
63
|
-
- Aggregation comparison (depending on data type)
|
|
64
|
-
- "group by" comparison
|
|
65
|
-
- Pandas DataFrame comparison (with a threshold for the size of the object)
|
|
66
|
-
- Pandas DataFrame sample comparison (with a random sample of the object)
|
|
67
|
-
- Detailed representation of the comparison result
|
|
68
|
-
- "high-level" result (for each pipeline/execution)
|
|
69
|
-
- "object-level" result (for each table/view)
|
|
70
|
-
- "column-level" result (for each column)
|
|
71
|
-
- Parallelization for performance enhancement of the comparison of a large number of objects
|
|
72
|
-
- Input testsets (white-listing of objects)
|
|
73
|
-
- Object filter (black-listing of objects)
|
|
74
|
-
- Object mappings between the source and the target system
|
|
75
|
-
- Comparison result saved and displayed in multiple instances
|
|
76
|
-
- saved as JSON files in the repository
|
|
77
|
-
- export to result tables in the target system (Snowflake or Databricks)
|
|
78
|
-
- export to Azure Blob Storage or AWS S3 Bucket
|
|
79
|
-
|
|
80
|
-
### Repository Structure
|
|
81
|
-
|
|
82
|
-
The repository is structured in the following sections:
|
|
83
|
-
|
|
84
|
-
- **icsDataValidation**
|
|
85
|
-
> This is where all code files are stored.
|
|
86
|
-
|
|
87
|
-
- **icsDataValidation/main.py**
|
|
88
|
-
> Entry point for python.
|
|
89
|
-
|
|
90
|
-
- **icsDataValidation/core**
|
|
91
|
-
> Main code files for the parts independent on the source and target system.
|
|
92
|
-
|
|
93
|
-
- **icsDataValidation/services/database_services**
|
|
94
|
-
> Database services for all supported systems can be found here.
|
|
95
|
-
Each file contains a class that is identically structured in comparison to the other database service classes.
|
|
96
|
-
Each database service class contains methods to query metadata, create aggregations, and retrieve data for the comparison step.
|
|
97
|
-
|
|
98
|
-
- **icsDataValidation/connection_setups**
|
|
99
|
-
> The connection setups are database dependent.
|
|
100
|
-
They define how the credentials for the database connections are retrieved.
|
|
101
|
-
|
|
102
|
-
- **examples/comparison_results**
|
|
103
|
-
> The comparison results are saved here.
|
|
104
|
-
One JSON file with all results is saved for each execution/pipeline run.
|
|
105
|
-
Additionally there are live comparison results saved for each compared object as a failsafe.
|
|
106
|
-
|
|
107
|
-
- **examples**
|
|
108
|
-
> This folder contains all files defining a specific validation setup.
|
|
109
|
-
- A file named `migration_config.json` contains configurations about the source system, the target system and the mapping of objects between both. It contains the blacklists and "group by" aggregation settings.
|
|
110
|
-
- A file named `ics_data_validation_config.json` specifies the source system, the target system and the results system. Most importantly, this includes the names of the results tables and the connection configurations (Server, Port, Secrets) of source and target system.
|
|
111
|
-
- A file named `manual_execution_params.py` is only relevant for local execution of the code. It contains settings which would otherwise be defined in the pipeline setup, i.e. limits on the size of objects to compare and the numeric precision.
|
|
112
|
-
- The folder `testsets` contains JSON files specifying whitelists of objects to compare.
|
|
113
|
-
|
|
114
|
-
For all the files here, empty `*.template.*` files are available and may serve as a starting point.
|
|
115
|
-
This repo stores only template files.
|
|
116
|
-
The actual files used for each setup should not be committed here.
|
|
117
|
-
They are stored in [a separate repository.](https://dev.azure.com/initions-consulting/icsDataValidation/_git/icsDataValidation%20-%20workflow%20demo).
|
|
118
|
-
|
|
119
|
-
- **examples/pipeline**
|
|
120
|
-
> Files defining the pipelines that execute the icsDV are stored here. For example, YML files for Azure DevOps pipelines.
|
|
121
|
-
|
|
122
|
-
## icsDV - Execution Manual
|
|
123
|
-
|
|
124
|
-
## icsDV - Input Parameters
|
|
125
|
-
|
|
126
|
-
There are four types of input parameters:
|
|
127
|
-
|
|
128
|
-
1. Pipeline Parameters - which are defined as input parameters of a pipeline (Azure DevOps Pipeline or Gitlab Pipeline).
|
|
129
|
-
2. Manual Execution Parameters - defined in the code (testing_tool.py).
|
|
130
|
-
They correspond to the Pipeline Parameters and are used when executing the code directly without a pipeline instead of the Pipeline Parameters.
|
|
131
|
-
3. Global Parameters - directly defined in the TestingToolParams class. They are used in pipeline runs and for manual executions.
|
|
132
|
-
4. Environmental Parameters - Stored either in Azure DevOps in a variable group, in Gitlab, or, for manual executions, in a `*.env` file in a location that can be specified in the `manual_execution_params.py`.
|
|
133
|
-
|
|
134
|
-
Additionally the parameters can be categorized into 3 groups:
|
|
135
|
-
|
|
136
|
-
1. Setup Parameters - these are parameters which are usually just set once when setting up the icsDV.
|
|
137
|
-
2. Configuration Parameters - are used to configure the general settings but can be adjusted to the conditions of the workload on the fly.
|
|
138
|
-
3. Execution Parameters - are set individually for each execution of the icsDV, e.g. the selection of objects to be tested.
|
|
139
|
-
|
|
140
|
-
### Setup Parameters
|
|
141
|
-
|
|
142
|
-
Stored in `ics_data_validation_config.json`:
|
|
143
|
-
|
|
144
|
-
| Parameter | Description | Input Type |
|
|
145
|
-
|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
|
|
146
|
-
| source_system_selection | Name of the source system as defined in the database_config.json as a key. | Pipeline Parameter or Manual Execution Parameter |
|
|
147
|
-
| target_system_selection | Name of the target system as defined in the database_config.json as a key. | Pipeline Parameter or Manual Execution Parameter |
|
|
148
|
-
| result_system_selection | Name of the result system as defined in the database_config.json as a key. | Pipeline Parameter or Manual Execution Parameter |
|
|
149
|
-
| azure_devops_pipeline | Azure DevOps Pipeline support. Set to "True" to push the changes of a run to the GIT repository. | Global Parameter - TestingToolParams |
|
|
150
|
-
| gitlab_pipeline | Gitlab Pipeline support. Set to "True" to push the changes of a run to the GIT repository. | Global Parameter - TestingToolParams |
|
|
151
|
-
| result_database_name | Name of the database or catalog the results are written to | Global Parameter - TestingToolParams |
|
|
152
|
-
| result_schema_name | Name of the schema the results are written to | Global Parameter - TestingToolParams |
|
|
153
|
-
| result_table_highlevel_name | Name of the high-level results table | Global Parameter - TestingToolParams |
|
|
154
|
-
| result_table_objectlevel_name | Name of the object-level results table | Global Parameter - TestingToolParams |
|
|
155
|
-
| result_table_columnlevel_name | Name of the column-level results table | Global Parameter - TestingToolParams |
|
|
156
|
-
| result_meta_data_schema_name | Name of the schema the full results are written to | Global Parameter - TestingToolParams |
|
|
157
|
-
| result_table_name | Name of the table the full results are written to | Global Parameter - TestingToolParams |
|
|
158
|
-
| result_live_table_name | Name of the table the live results are written to | Global Parameter - TestingToolParams |
|
|
159
|
-
| results_folder_name | Folder that in which the results are stored in JSON format. Default: `examples/comparison_results/` | Global Parameter - TestingToolParams |
|
|
160
|
-
| remaining_mapping_objects_folder_name | Output folder that holds information about source system objects which are not covered by the mapping and are therefor not included in the comparison. Default: `examples/remaining_mapping_objects/` | Global Parameter - TestingToolParams |
|
|
161
|
-
| testset_folder_name | Folder that holds the test set files in JSON format. Default: `examples/testsets/` | Global Parameter - TestingToolParams |
|
|
162
|
-
| stage_schema | Name of the Snowflake Schema where the stage is created to upload the comparison results to Snowflake. Only needed if the `upload_result_to_result_database` functionality is used with Snowflake as target system. | Global Parameter - TestingToolParams |
|
|
163
|
-
| stage_name_prefix | Prefix of the name of the Snowflake Stage which is used to upload the comparison results to Snowflake. The name is complemented by a run_guid which is a unique uuid for each icsDV execution. Only needed if the `upload_result_to_result_database` functionality is used. | Global Parameter - TestingToolParams |
|
|
164
|
-
| container_name | Name of the Azure Storage Container to upload the comparison results into the blob storage. Note: Only needed if the `upload_result_to_blob` functionality is used. | Global Parameter - TestingToolParams |
|
|
165
|
-
| bucket_name | Name of the AWS S3 Bucket to upload the comparison results into the AWS. Note: Only needed if the `upload_result_to_bucket` functionality is used. | Global Parameter - TestingToolParams |
|
|
166
|
-
|
|
167
|
-
### Configuration Parameters
|
|
168
|
-
|
|
169
|
-
Stored in `manual_execution_params.py`:
|
|
170
|
-
|
|
171
|
-
| Parameter | Description | Input Type |
|
|
172
|
-
|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
|
|
173
|
-
| ENV_FILEPATH | Absolute path to the `*.env` file containing secrets, passwords and tokens. | Pipeline Parameter or Manual Execution Parameters |
|
|
174
|
-
| UPLOAD_RESULT_TO_BLOB | Set to "True" to upload the comparison results to an Azure Blob Storage. An `azure_storage_connection_string` is needed if set to "True". | Pipeline Parameter or Manual Execution Parameters |
|
|
175
|
-
| UPLOAD_RESULT_TO_BUCKET | Set to "True" to upload the comparison results to an AWS S3 Bucket. An `aws_bucket_access_key` and an `aws_bucket_secret_key` is needed if set to "True". | Pipeline Parameter or Manual Execution Parameter |
|
|
176
|
-
| UPLOAD_RESULT_TO_RESULT_DATABASE | Set to "True" to upload the comparison results to Snowflake or Databricks. A `result_system_selection` is needed if set to "True". | Pipeline Parameter or Manual Execution Parameter |
|
|
177
|
-
| MAX_OBJECT_SIZE | Limits Pandas comparison to objects of a size smaller than `MAX_OBJECT_SIZE` bytes. Data type is String. Default: `str(-1)`, no limit. | Pipeline Parameter or Manual Execution Parameter |
|
|
178
|
-
| MAX_ROW_NUMBER | Limits Pandas comparison to objects with less than `MAX_ROW_NUMBER` rows. Data type is String. Default: `str(-1)`, no limit. | Pipeline Parameter or Manual Execution Parameter |
|
|
179
|
-
| EXECUTE_GROUP_BY_COMPARISON | Set to "True" to execute group-by comparisons. See sec. "Group-By-Aggregation" for details. | Pipeline Parameter or Manual Execution Parameter |
|
|
180
|
-
| USE_GROUP_BY_COLUMNS | Set to "True" to activate group-by columns. See sec. "Group-By-Aggregation" for details. | Pipeline Parameter or Manual Execution Parameter |
|
|
181
|
-
| MIN_GROUP_BY_COUNT_DISTINCT | Minimum expected number of group-by counts. See sec. "Group-By-Aggregation" for details. | Pipeline Parameter or Manual Execution Parameter |
|
|
182
|
-
| MAX_GROUP_BY_COUNT_DISTINCT | Maximum expected number of group-by counts. See sec. "Group-By-Aggregation" for details. | Pipeline Parameter or Manual Execution Parameter |
|
|
183
|
-
| MAX_GROUP_BY_SIZE | Maximum size of the group-by query. See sec. "Group-By-Aggregation" for details. | Pipeline Parameter or Manual Execution Parameter |
|
|
184
|
-
| NUMERIC_SCALE | Number of digits to compare. Data type is String. Default: `str(2)`, i.e. deviations below 0.01 are tolerated. | Pipeline Parameter or Manual Execution Parameter |
|
|
185
|
-
|
|
186
|
-
### Execution Parameters
|
|
187
|
-
|
|
188
|
-
Stored in `manual_execution_params.py`:
|
|
189
|
-
|
|
190
|
-
| Parameter | Description | Input Type |
|
|
191
|
-
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
|
|
192
|
-
| DATABASE_NAME | Filters the test set on a specific database/catalog. For no filter set "None" as a Manual Execution Parameter and leave it empty as a Pipeline Parameter. | Pipeline Parameter or Manual Execution Parameter |
|
|
193
|
-
| SCHEMA_NAME | Filters the test set on a specific schema. For no filter set "None" as a Manual Execution Parameter and leave it empty as a Pipeline Parameter. | Pipeline Parameter or Manual Execution Parameter |
|
|
194
|
-
| TESTSET_FILE_NAMES | File names of the test set as defined in the folder testset_folder_name (see Setup Parameters) as JSON files. | Pipeline Parameter or Manual Execution Parameter |
|
|
195
|
-
| OBJECT_TYPE_RESTRICTION | Filters the testset to only tables (`"include_only_tables"`), only views (`"include_only_views"`) or all tables and views (`"include_all"`). | Pipeline Parameter or Manual Execution Parameter |
|
|
196
|
-
| MAX_NUMBER_OF_THREADS | Maximum number of threads used. Values larget than the default, `str(1)`, activate parallelization. | Pipeline Parameter or Manual Execution Parameter |
|
|
197
|
-
|
|
198
|
-
## icsDV - Configuration
|
|
199
|
-
|
|
200
|
-
### Blacklists
|
|
201
|
-
|
|
202
|
-
### Whitelists (Testsets)
|
|
203
|
-
|
|
204
|
-
### Mapping
|
|
205
|
-
|
|
206
|
-
### Group-By-Aggregation
|
|
207
|
-
|
|
208
|
-
The Group-By-Aggregation is a feature to pinpoint the differences in the data.
|
|
209
|
-
It can be activiated by setting the parameter `EXECUTE_GROUP_BY_COMPARISON` to TRUE.
|
|
210
|
-
If activated an additional comparison step is performed.
|
|
211
|
-
Each table is queried with a group-by-statement including aggregations depending on the data type.
|
|
212
|
-
Those aggregations are consequently compared.
|
|
213
|
-
As a result the differences in the data can be narrowed down to certain grouping values.
|
|
214
|
-
|
|
215
|
-
There are three options to define the column over which the group-by is executed.
|
|
216
|
-
|
|
217
|
-
1. "group-by-columns-per-table" defined as multiple lists for specific tables. Activated with the `USE_GROUP_BY_COLUMNS` parameter and `GROUP_BY_COLUMNS_PER_TABLE` defined in the `migration_config.json`.
|
|
218
|
-
2. "group-by-columns" from a predifined list for all tables by a validation. Activated with the `USE_GROUP_BY_COLUMNS` parameter and `GROUP_BY_COLUMNS` defined in the `migration_config.json`.
|
|
219
|
-
3. "group-by-columns" evaluated from all existing columns by a validation
|
|
220
|
-
|
|
221
|
-
The validation consists of a number of tests and can be configured by a number of parameters to either easily find columns to group by over or to only select columns which add a definite value for pinpointing the differences in the data.
|
|
222
|
-
|
|
223
|
-
The validation tests for the "group-by-columns" are:
|
|
224
|
-
|
|
225
|
-
1. Number of distinct values of the column is more than 1.
|
|
226
|
-
2. Number of distinct values of the column is less than the rowcount of the table.
|
|
227
|
-
3. Number of distinct values of the column exceeds the `MIN_GROUP_BY_COUNT_DISTINCT` parameter.
|
|
228
|
-
4. Number of distinct values of the column is below the `MAX_GROUP_BY_COUNT_DISTINCT` parameter.
|
|
229
|
-
5. The size of the expected result of the group-by-query is below the `MAX_GROUP_BY_SIZE` parameter.
|
|
230
|
-
(The size is defined by "Number of distinct values" * "Number of columns")
|
|
231
|
-
|
|
232
|
-
All tests are executed on source and target.
|
|
233
|
-
|
|
234
|
-
> Note: The group by comparison can be activated by setting the `execute_group_by_comparison` parameter to TRUE.
|
|
235
|
-
The `migration_config.json` has to include the follwing keys when the parameter use_group_by_columns is set to TRUE.
|
|
236
|
-
|
|
237
|
-
"GROUP_BY_AGGREGATION":{
|
|
238
|
-
"GROUP_BY_COLUMNS_PER_TABLE": {},
|
|
239
|
-
"GROUP_BY_COLUMNS":[]
|
|
240
|
-
}
|
|
241
|
-
The values of those keys can be empty.
|
|
242
|
-
|
|
243
|
-
## icsDV - Comparison Results
|
|
244
|
-
|
|
245
|
-
### JSON Results
|
|
246
|
-
|
|
247
|
-
- Complete Comparison Result JSONs
|
|
248
|
-
- Live Comparison Result JSONs
|
|
249
|
-
|
|
250
|
-
### Target System Result Tables
|
|
251
|
-
|
|
252
|
-
- High-Level Result
|
|
253
|
-
- Object-Level Result
|
|
254
|
-
- Column-Level Result
|
|
255
|
-
|
|
256
|
-
### Result Export in a File Storage
|
|
257
|
-
|
|
258
|
-
## icsDV - Setup
|
|
259
|
-
|
|
260
|
-
### Code setup
|
|
261
|
-
|
|
262
|
-
- To handle the code, we recommend using VS Code.
|
|
263
|
-
- The code is written in python. The tool is compatible with version 3.11
|
|
264
|
-
- It is recommended to use a project-specific python environment.
|
|
265
|
-
You can create one with `python -m venv .env` in the root folder of this repo.
|
|
266
|
-
After creating it, you should activate it (`source .env/bin/activate`), select the python binary `.env/bin/python` therein as your python interpreter in VSC and make sure that python libraries are read from and installed to this environment, i.e. `export PYTHONPATH=$(pwd)/.env/lib/python3.8/site-packages`.
|
|
267
|
-
- In this environment, install the packages listed in the `requirements.txt` and the `requirements-dev.txt`. i.e. run `pip install -r requirements.txt`.
|
|
268
|
-
|
|
269
|
-
### Setup for manual execution
|
|
270
|
-
|
|
271
|
-
### Setup as Azure DevOps pipeline
|
|
272
|
-
|
|
273
|
-
### Setup as GitLab pipeline
|
|
274
|
-
|
|
275
|
-
## authentication
|
|
276
|
-
|
|
277
|
-
The following auth methods to snowflake are supported:
|
|
278
|
-
|
|
279
|
-
- password, provided via PASSWORD_NAME
|
|
280
|
-
- private key with/without encryption, provided via PRIVATE_KEY_NAME with/without PRIVATE_KEY_PASSPHRASE_NAME
|
|
281
|
-
- path to private key file with/without encryption, provided via PRIVATE_KEY_FILE_PATH with/without PRIVATE_KEY_FILE_PASSWORD
|
|
282
|
-
|
|
283
|
-
## devcontainer
|
|
284
|
-
|
|
285
|
-
run with uv as follows in devcontainer:
|
|
286
|
-
```bash
|
|
287
|
-
uv run -s icsDataValidation/main.py
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
Inside the [devcontainer config](.devcontainer/devcontainer.json) the mounts setting is used to bring a .env from the host system into the devcontainer.
|
|
291
|
-
|
|
292
|
-
```bash
|
|
293
|
-
"mounts": [
|
|
294
|
-
"source=/home/Documents/Generic_Testing_Tool/generic_testing_tool_password.env,target=/workspaces/icsDataValidation/examples/generic_testing_tool_password.env,type=bind"
|
|
295
|
-
]
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
To use this feature either create the .env under the source path on your host or adjust this path to another path on the host system. The target path do no need adjustment!
|
|
File without changes
|
|
File without changes
|