google-pso-data-validator 4.3.0__tar.gz → 4.4.0__tar.gz
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.
- {google-pso-data-validator-4.3.0/google_pso_data_validator.egg-info → google-pso-data-validator-4.4.0}/PKG-INFO +59 -19
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/README.md +58 -18
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/__main__.py +87 -11
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/cli_tools.py +29 -10
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/combiner.py +13 -1
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/config_manager.py +53 -25
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/consts.py +1 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/partition_builder.py +35 -10
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/state_manager.py +12 -1
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0/google_pso_data_validator.egg-info}/PKG-INFO +59 -19
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/google_pso_data_validator.egg-info/SOURCES.txt +1 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/setup.py +1 -1
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_addon/operations.py +42 -24
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mssql/datatypes.py +2 -2
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_oracle/__init__.py +7 -1
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_oracle/datatypes.py +10 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_oracle/registry.py +9 -18
- google-pso-data-validator-4.4.0/third_party/ibis/ibis_postgres/__init__.py +2 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_postgres/client.py +49 -2
- google-pso-data-validator-4.4.0/third_party/ibis/ibis_postgres/datatypes.py +22 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_teradata/__init__.py +12 -1
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_teradata/registry.py +8 -0
- google-pso-data-validator-4.3.0/third_party/ibis/ibis_snowflake/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/LICENSE +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/app.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/client_info.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/clients.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/data_validation.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/exceptions.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/jellyfish_distance.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/metadata.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/query_builder/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/query_builder/partition_row_builder.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/query_builder/query_builder.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/query_builder/random_row_builder.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/result_handlers/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/result_handlers/bigquery.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/result_handlers/text.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/schema_validation.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/secret_manager.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/validation_builder.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/google_pso_data_validator.egg-info/dependency_links.txt +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/google_pso_data_validator.egg-info/entry_points.txt +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/google_pso_data_validator.egg-info/requires.txt +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/google_pso_data_validator.egg-info/top_level.txt +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/setup.cfg +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_addon/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_addon/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/client.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/compiler.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/datatypes.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/registry.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/tests/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/tests/conftest.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_cloud_spanner/to_pandas.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_db2/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_db2/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_db2/compiler.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_db2/datatypes.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_db2/registry.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_impala/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_impala/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mssql/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mssql/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mysql/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mysql/base_sql_compiler/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mysql/base_sql_compiler/select_builder.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_mysql/compiler.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_oracle/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_oracle/compiler.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_redshift/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_redshift/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_redshift/compiler.py +0 -0
- {google-pso-data-validator-4.3.0/third_party/ibis/ibis_postgres → google-pso-data-validator-4.4.0/third_party/ibis/ibis_snowflake}/__init__.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_snowflake/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_snowflake/datatypes.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_teradata/api.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_teradata/compiler.py +0 -0
- {google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/third_party/ibis/ibis_teradata/datatypes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-pso-data-validator
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4.0
|
|
4
4
|
Summary: A package to enable easy data validation
|
|
5
5
|
Home-page: https://github.com/pypa/sampleproject
|
|
6
6
|
Author: Dylan Hercher
|
|
@@ -101,8 +101,8 @@ setup steps needed to install and use the Data Validation Tool.
|
|
|
101
101
|
Before using this tool, you will need to create connections to the source and
|
|
102
102
|
target tables. Once the connections are created, you can run validations on
|
|
103
103
|
those tables. Validation results can be printed to stdout (default) or outputted
|
|
104
|
-
to BigQuery (recommended). DVT also allows you to save
|
|
105
|
-
configurations in a YAML file. This is useful for running common validations or
|
|
104
|
+
to BigQuery (recommended). DVT also allows you to save and edit validation
|
|
105
|
+
configurations in a YAML or JSON file. This is useful for running common validations or
|
|
106
106
|
updating the configuration.
|
|
107
107
|
|
|
108
108
|
### Managing Connections
|
|
@@ -121,6 +121,8 @@ Alternatives to running DVT in the CLI include deploying DVT to Cloud Run, Cloud
|
|
|
121
121
|
([Examples Here](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples)). See the [Validation Logic](https://github.com/GoogleCloudPlatform/professional-services-data-validator#validation-logic) section
|
|
122
122
|
to learn more about how DVT uses the CLI to generate SQL queries.
|
|
123
123
|
|
|
124
|
+
Note that we do not support nested or complex columns for column or row validations.
|
|
125
|
+
|
|
124
126
|
#### Column Validations
|
|
125
127
|
|
|
126
128
|
Below is the command syntax for column validations. To run a grouped column
|
|
@@ -146,9 +148,6 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
146
148
|
i.e 'bigquery-public-data.new_york_citibike.citibike_trips'
|
|
147
149
|
[--grouped-columns or -gc GROUPED_COLUMNS]
|
|
148
150
|
Comma separated list of columns for Group By i.e col_a,col_b
|
|
149
|
-
[--primary-keys or -pk PRIMARY_KEYS]
|
|
150
|
-
Comma separated list of columns to use as primary keys
|
|
151
|
-
(Note) Only use with grouped column validation. See *Primary Keys* section.
|
|
152
151
|
[--count COLUMNS] Comma separated list of columns for count or * for all columns
|
|
153
152
|
[--sum COLUMNS] Comma separated list of columns for sum or * for all numeric
|
|
154
153
|
[--min COLUMNS] Comma separated list of columns for min or * for all numeric
|
|
@@ -172,7 +171,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
172
171
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
173
172
|
See: *Filters* section
|
|
174
173
|
[--config-file or -c CONFIG_FILE]
|
|
175
|
-
YAML Config File Path to be used for storing validations.
|
|
174
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
175
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
176
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
177
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
176
178
|
[--threshold or -th THRESHOLD]
|
|
177
179
|
Float value. Maximum pct_difference allowed for validation to be considered a success. Defaults to 0.0
|
|
178
180
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
@@ -183,8 +185,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
183
185
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
184
186
|
```
|
|
185
187
|
|
|
186
|
-
The default aggregation type is a 'COUNT *'
|
|
187
|
-
|
|
188
|
+
The default aggregation type is a 'COUNT *', which will run in addition to the validations you specify. To remove this default,
|
|
189
|
+
use [YAML configs](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop#running-dvt-with-yaml-configuration-files).
|
|
188
190
|
|
|
189
191
|
The [Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md) page provides many examples of how a tool can be used to run powerful validations without writing any queries.
|
|
190
192
|
|
|
@@ -208,7 +210,7 @@ and finally hashing the row.
|
|
|
208
210
|
|
|
209
211
|
Under the hood, row validation uses
|
|
210
212
|
[Calculated Fields](https://github.com/GoogleCloudPlatform/professional-services-data-validator#calculated-fields) to
|
|
211
|
-
apply functions such as IFNULL() or RTRIM(). These can be edited in the YAML config to customize your row validation.
|
|
213
|
+
apply functions such as IFNULL() or RTRIM(). These can be edited in the YAML or JSON config file to customize your row validation.
|
|
212
214
|
|
|
213
215
|
```
|
|
214
216
|
data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
@@ -239,7 +241,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
|
239
241
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
240
242
|
See: *Filters* section
|
|
241
243
|
[--config-file or -c CONFIG_FILE]
|
|
242
|
-
YAML Config File Path to be used for storing validations.
|
|
244
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
245
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
246
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
247
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
243
248
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
244
249
|
Comma-separated key value pair labels for the run.
|
|
245
250
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -316,7 +321,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate schema
|
|
|
316
321
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
317
322
|
Service account to use for BigQuery result handler output.
|
|
318
323
|
[--config-file or -c CONFIG_FILE]
|
|
319
|
-
YAML Config File Path to be used for storing validations.
|
|
324
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
325
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
326
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
327
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
320
328
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
321
329
|
Defaults to table.
|
|
322
330
|
[--filter-status or -fs STATUSES_LIST]
|
|
@@ -366,6 +374,11 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query col
|
|
|
366
374
|
See: *Validation Reports* section
|
|
367
375
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
368
376
|
Service account to use for BigQuery result handler output.
|
|
377
|
+
[--config-file or -c CONFIG_FILE]
|
|
378
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
379
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
380
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
381
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
369
382
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
370
383
|
Comma-separated key value pair labels for the run.
|
|
371
384
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -423,6 +436,11 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query row
|
|
|
423
436
|
See: *Validation Reports* section
|
|
424
437
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
425
438
|
Service account to use for BigQuery result handler output.
|
|
439
|
+
[--config-file or -c CONFIG_FILE]
|
|
440
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
441
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
442
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
443
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
426
444
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
427
445
|
Comma-separated key value pair labels for the run.
|
|
428
446
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -459,17 +477,19 @@ For example, this flag can be used as follows:
|
|
|
459
477
|
}
|
|
460
478
|
```
|
|
461
479
|
|
|
462
|
-
### YAML Configuration Files
|
|
480
|
+
### Running DVT with YAML Configuration Files
|
|
463
481
|
|
|
464
|
-
|
|
465
|
-
|
|
482
|
+
Running DVT with YAML configuration files is the recommended approach if:
|
|
483
|
+
* you want to customize the configuration for any given validation OR
|
|
484
|
+
* you want to run DVT at scale (i.e. row validations across many partitions)
|
|
485
|
+
Nearly every validation command can take the argument `-c <file-name>` (the `generate-table-partitions` command takes `-cdir <directory-name>`) where one or more yaml files are produced. These yaml files can be modified for custom validations.
|
|
466
486
|
|
|
467
|
-
|
|
487
|
+
The following command creates a YAML file for the validation of the
|
|
468
488
|
`new_york_citibike` table: `data-validation validate column -sc my_bq_conn -tc
|
|
469
489
|
my_bq_conn -tbls bigquery-public-data.new_york_citibike.citibike_trips -c
|
|
470
490
|
citibike.yaml`.
|
|
471
491
|
|
|
472
|
-
The
|
|
492
|
+
The validation config file is saved to the GCS path specified by the `PSO_DV_CONFIG_HOME`
|
|
473
493
|
env variable if that has been set; otherwise, it is saved to wherever the tool is run.
|
|
474
494
|
|
|
475
495
|
You can now edit the YAML file if, for example, the `new_york_citibike` table is
|
|
@@ -494,6 +514,26 @@ View the complete YAML file for a Grouped Column validation on the
|
|
|
494
514
|
[Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md#sample-yaml-config-grouped-column-validation) page.
|
|
495
515
|
|
|
496
516
|
You can view a list of all saved validation YAML files using `data-validation configs list`, and print a YAML config using `data-validation configs get -c citibike.yaml`.
|
|
517
|
+
#### Scaling DVT to run 10's to 1000's of validations concurrently
|
|
518
|
+
The above example `configs run -cdir` shows how you can run multiple validations with one command. If the directory used has been created by `generate-table-partitions`, you will have partition files numbered from `0000.yaml` to `<partno-1>.yaml`, where `<partno>` is the total number of partitions. These can be run as mentioned above and the partitions will be validated in order. This could take a long time if the number of partitions is large.
|
|
519
|
+
|
|
520
|
+
DVT validations can be run concurrently (horizontal scaling) using GKE (Kubernetes Jobs) or Cloud Run Jobs. In order to run DVT in a container, you have to build a docker image, [see instructions](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples/docker#readme). Set the `PSO_DV_CONFIG_HOME` environment variable to point to a GCS prefix where the connection configuration files are stored. In Cloud Run you can use the option `--set-env-vars` or `--update-env-vars` to pass [the environment variable](https://cloud.google.com/run/docs/configuring/services/environment-variables#setting). We recommend that you use the `bq-result-handler` to save your validation results. In order to validate partitions concurrently, run DVT in Kubernetes or Cloud Run as shown below:
|
|
521
|
+
```
|
|
522
|
+
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
523
|
+
[--kube-completions or -kc] Specifies that validation is being run in Kubernetes or Cloud Run in indexed completion mode.
|
|
524
|
+
specifies to DVT that validation being run in indexed completion mode in Kubernetes or as multiple independent tasks in Cloud Run.
|
|
525
|
+
--config-dir or -cdir GCS_DIRECTORY
|
|
526
|
+
where GCS_DIRECTORY = CONFIG_DIR/SOURCE_SCHEMA.SOURCE_TABLE, where CONFIG_DIR, SOURCE_SCHEMA and SOURCE_TABLE are
|
|
527
|
+
the arguments provided to generate-table-partitions to generate the partition yamls. GCS_DIRECTORY is the directory
|
|
528
|
+
where the partition files numbered 0000.yaml to <partno-1>.yaml are stored.
|
|
529
|
+
```
|
|
530
|
+
If you are not familiar with Kubernetes or Cloud Run Jobs, review the [internal docs](docs/internal/kubernetes_jobs.md) for an overview of the orchestration of multiple validations.
|
|
531
|
+
|
|
532
|
+
The Cloud Run and Kubernetes pods must run in a network with access to the database servers. Every Cloud Run job is associated with a [service account](https://cloud.google.com/run/docs/securing/service-identity). You need to ensure that this service account has access to Google Cloud Storage (to read connection configuration and yaml files) and BigQuery (to publish results). If you are using Kubernetes, you will need to use a service account with the same privileges as mentioned for Cloud Run. In Kubernetes, you will need to set up [workload identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) so the DVT container can impersonate the service account.
|
|
533
|
+
|
|
534
|
+
In Cloud Run, the [job](https://cloud.google.com/run/docs/create-jobs) must be run as multiple, independent tasks with the task count set to the number of partitions generated. In Kubernetes, set the number of completions to the number of partitions generated - see [Kubernetes Parallel Jobs](https://kubernetes.io/docs/concepts/workloads/controllers/job/#parallel-jobs). The option `--kube-completions or -kc` tells DVT that many DVT containers are running in a Kubernetes cluster. Each DVT container only validates the specific partition yaml (based on the index assigned by Kubernetes control plane). If the `-kc` option is used and you are not running in indexed mode, you will receive a warning and the container will process all the validations sequentially. If the `-kc` option is used and a config directory is not provided (a `--config-file` is provided instead), a warning is issued.
|
|
535
|
+
|
|
536
|
+
By default, each partition validation is retried up to 3 times if there is an error. In Kubernetes and Cloud Run, you can set the parallelism to the number you want. Keep in mind that if you are validating 1000's of partitions in parallel, you may find that setting the parallelism too high (say 100) may result in timeouts and slow down the validation.
|
|
497
537
|
|
|
498
538
|
### Validation Reports
|
|
499
539
|
|
|
@@ -650,7 +690,7 @@ significant figure.
|
|
|
650
690
|
|
|
651
691
|
Once a calculated field is defined, it can be referenced by other calculated
|
|
652
692
|
fields at any "depth" or higher. Depth controls how many subqueries are executed
|
|
653
|
-
in the resulting query. For example, with the following YAML config
|
|
693
|
+
in the resulting query. For example, with the following YAML config:
|
|
654
694
|
|
|
655
695
|
```yaml
|
|
656
696
|
- calculated_fields:
|
|
@@ -671,7 +711,7 @@ in the resulting query. For example, with the following YAML config...
|
|
|
671
711
|
depth: 1 # calculated one query above
|
|
672
712
|
```
|
|
673
713
|
|
|
674
|
-
is equivalent to the following SQL query
|
|
714
|
+
is equivalent to the following SQL query:
|
|
675
715
|
|
|
676
716
|
```sql
|
|
677
717
|
SELECT
|
|
@@ -53,8 +53,8 @@ setup steps needed to install and use the Data Validation Tool.
|
|
|
53
53
|
Before using this tool, you will need to create connections to the source and
|
|
54
54
|
target tables. Once the connections are created, you can run validations on
|
|
55
55
|
those tables. Validation results can be printed to stdout (default) or outputted
|
|
56
|
-
to BigQuery (recommended). DVT also allows you to save
|
|
57
|
-
configurations in a YAML file. This is useful for running common validations or
|
|
56
|
+
to BigQuery (recommended). DVT also allows you to save and edit validation
|
|
57
|
+
configurations in a YAML or JSON file. This is useful for running common validations or
|
|
58
58
|
updating the configuration.
|
|
59
59
|
|
|
60
60
|
### Managing Connections
|
|
@@ -73,6 +73,8 @@ Alternatives to running DVT in the CLI include deploying DVT to Cloud Run, Cloud
|
|
|
73
73
|
([Examples Here](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples)). See the [Validation Logic](https://github.com/GoogleCloudPlatform/professional-services-data-validator#validation-logic) section
|
|
74
74
|
to learn more about how DVT uses the CLI to generate SQL queries.
|
|
75
75
|
|
|
76
|
+
Note that we do not support nested or complex columns for column or row validations.
|
|
77
|
+
|
|
76
78
|
#### Column Validations
|
|
77
79
|
|
|
78
80
|
Below is the command syntax for column validations. To run a grouped column
|
|
@@ -98,9 +100,6 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
98
100
|
i.e 'bigquery-public-data.new_york_citibike.citibike_trips'
|
|
99
101
|
[--grouped-columns or -gc GROUPED_COLUMNS]
|
|
100
102
|
Comma separated list of columns for Group By i.e col_a,col_b
|
|
101
|
-
[--primary-keys or -pk PRIMARY_KEYS]
|
|
102
|
-
Comma separated list of columns to use as primary keys
|
|
103
|
-
(Note) Only use with grouped column validation. See *Primary Keys* section.
|
|
104
103
|
[--count COLUMNS] Comma separated list of columns for count or * for all columns
|
|
105
104
|
[--sum COLUMNS] Comma separated list of columns for sum or * for all numeric
|
|
106
105
|
[--min COLUMNS] Comma separated list of columns for min or * for all numeric
|
|
@@ -124,7 +123,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
124
123
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
125
124
|
See: *Filters* section
|
|
126
125
|
[--config-file or -c CONFIG_FILE]
|
|
127
|
-
YAML Config File Path to be used for storing validations.
|
|
126
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
127
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
128
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
129
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
128
130
|
[--threshold or -th THRESHOLD]
|
|
129
131
|
Float value. Maximum pct_difference allowed for validation to be considered a success. Defaults to 0.0
|
|
130
132
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
@@ -135,8 +137,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
135
137
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
136
138
|
```
|
|
137
139
|
|
|
138
|
-
The default aggregation type is a 'COUNT *'
|
|
139
|
-
|
|
140
|
+
The default aggregation type is a 'COUNT *', which will run in addition to the validations you specify. To remove this default,
|
|
141
|
+
use [YAML configs](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop#running-dvt-with-yaml-configuration-files).
|
|
140
142
|
|
|
141
143
|
The [Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md) page provides many examples of how a tool can be used to run powerful validations without writing any queries.
|
|
142
144
|
|
|
@@ -160,7 +162,7 @@ and finally hashing the row.
|
|
|
160
162
|
|
|
161
163
|
Under the hood, row validation uses
|
|
162
164
|
[Calculated Fields](https://github.com/GoogleCloudPlatform/professional-services-data-validator#calculated-fields) to
|
|
163
|
-
apply functions such as IFNULL() or RTRIM(). These can be edited in the YAML config to customize your row validation.
|
|
165
|
+
apply functions such as IFNULL() or RTRIM(). These can be edited in the YAML or JSON config file to customize your row validation.
|
|
164
166
|
|
|
165
167
|
```
|
|
166
168
|
data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
@@ -191,7 +193,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
|
191
193
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
192
194
|
See: *Filters* section
|
|
193
195
|
[--config-file or -c CONFIG_FILE]
|
|
194
|
-
YAML Config File Path to be used for storing validations.
|
|
196
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
197
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
198
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
199
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
195
200
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
196
201
|
Comma-separated key value pair labels for the run.
|
|
197
202
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -268,7 +273,10 @@ data-validation (--verbose or -v) (--log-level or -ll) validate schema
|
|
|
268
273
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
269
274
|
Service account to use for BigQuery result handler output.
|
|
270
275
|
[--config-file or -c CONFIG_FILE]
|
|
271
|
-
YAML Config File Path to be used for storing validations.
|
|
276
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
277
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
278
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
279
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
272
280
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
273
281
|
Defaults to table.
|
|
274
282
|
[--filter-status or -fs STATUSES_LIST]
|
|
@@ -318,6 +326,11 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query col
|
|
|
318
326
|
See: *Validation Reports* section
|
|
319
327
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
320
328
|
Service account to use for BigQuery result handler output.
|
|
329
|
+
[--config-file or -c CONFIG_FILE]
|
|
330
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
331
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
332
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
333
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
321
334
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
322
335
|
Comma-separated key value pair labels for the run.
|
|
323
336
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -375,6 +388,11 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query row
|
|
|
375
388
|
See: *Validation Reports* section
|
|
376
389
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
377
390
|
Service account to use for BigQuery result handler output.
|
|
391
|
+
[--config-file or -c CONFIG_FILE]
|
|
392
|
+
YAML Config File Path to be used for storing validations and other features.
|
|
393
|
+
See: *Running DVT with YAML Configuration Files* section
|
|
394
|
+
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
395
|
+
JSON Config File Path to be used for storing validations only for application purposes.
|
|
378
396
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
379
397
|
Comma-separated key value pair labels for the run.
|
|
380
398
|
[--format or -fmt] Format for stdout output. Supported formats are (text, csv, json, table).
|
|
@@ -411,17 +429,19 @@ For example, this flag can be used as follows:
|
|
|
411
429
|
}
|
|
412
430
|
```
|
|
413
431
|
|
|
414
|
-
### YAML Configuration Files
|
|
432
|
+
### Running DVT with YAML Configuration Files
|
|
415
433
|
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
Running DVT with YAML configuration files is the recommended approach if:
|
|
435
|
+
* you want to customize the configuration for any given validation OR
|
|
436
|
+
* you want to run DVT at scale (i.e. row validations across many partitions)
|
|
437
|
+
Nearly every validation command can take the argument `-c <file-name>` (the `generate-table-partitions` command takes `-cdir <directory-name>`) where one or more yaml files are produced. These yaml files can be modified for custom validations.
|
|
418
438
|
|
|
419
|
-
|
|
439
|
+
The following command creates a YAML file for the validation of the
|
|
420
440
|
`new_york_citibike` table: `data-validation validate column -sc my_bq_conn -tc
|
|
421
441
|
my_bq_conn -tbls bigquery-public-data.new_york_citibike.citibike_trips -c
|
|
422
442
|
citibike.yaml`.
|
|
423
443
|
|
|
424
|
-
The
|
|
444
|
+
The validation config file is saved to the GCS path specified by the `PSO_DV_CONFIG_HOME`
|
|
425
445
|
env variable if that has been set; otherwise, it is saved to wherever the tool is run.
|
|
426
446
|
|
|
427
447
|
You can now edit the YAML file if, for example, the `new_york_citibike` table is
|
|
@@ -446,6 +466,26 @@ View the complete YAML file for a Grouped Column validation on the
|
|
|
446
466
|
[Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md#sample-yaml-config-grouped-column-validation) page.
|
|
447
467
|
|
|
448
468
|
You can view a list of all saved validation YAML files using `data-validation configs list`, and print a YAML config using `data-validation configs get -c citibike.yaml`.
|
|
469
|
+
#### Scaling DVT to run 10's to 1000's of validations concurrently
|
|
470
|
+
The above example `configs run -cdir` shows how you can run multiple validations with one command. If the directory used has been created by `generate-table-partitions`, you will have partition files numbered from `0000.yaml` to `<partno-1>.yaml`, where `<partno>` is the total number of partitions. These can be run as mentioned above and the partitions will be validated in order. This could take a long time if the number of partitions is large.
|
|
471
|
+
|
|
472
|
+
DVT validations can be run concurrently (horizontal scaling) using GKE (Kubernetes Jobs) or Cloud Run Jobs. In order to run DVT in a container, you have to build a docker image, [see instructions](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples/docker#readme). Set the `PSO_DV_CONFIG_HOME` environment variable to point to a GCS prefix where the connection configuration files are stored. In Cloud Run you can use the option `--set-env-vars` or `--update-env-vars` to pass [the environment variable](https://cloud.google.com/run/docs/configuring/services/environment-variables#setting). We recommend that you use the `bq-result-handler` to save your validation results. In order to validate partitions concurrently, run DVT in Kubernetes or Cloud Run as shown below:
|
|
473
|
+
```
|
|
474
|
+
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
475
|
+
[--kube-completions or -kc] Specifies that validation is being run in Kubernetes or Cloud Run in indexed completion mode.
|
|
476
|
+
specifies to DVT that validation being run in indexed completion mode in Kubernetes or as multiple independent tasks in Cloud Run.
|
|
477
|
+
--config-dir or -cdir GCS_DIRECTORY
|
|
478
|
+
where GCS_DIRECTORY = CONFIG_DIR/SOURCE_SCHEMA.SOURCE_TABLE, where CONFIG_DIR, SOURCE_SCHEMA and SOURCE_TABLE are
|
|
479
|
+
the arguments provided to generate-table-partitions to generate the partition yamls. GCS_DIRECTORY is the directory
|
|
480
|
+
where the partition files numbered 0000.yaml to <partno-1>.yaml are stored.
|
|
481
|
+
```
|
|
482
|
+
If you are not familiar with Kubernetes or Cloud Run Jobs, review the [internal docs](docs/internal/kubernetes_jobs.md) for an overview of the orchestration of multiple validations.
|
|
483
|
+
|
|
484
|
+
The Cloud Run and Kubernetes pods must run in a network with access to the database servers. Every Cloud Run job is associated with a [service account](https://cloud.google.com/run/docs/securing/service-identity). You need to ensure that this service account has access to Google Cloud Storage (to read connection configuration and yaml files) and BigQuery (to publish results). If you are using Kubernetes, you will need to use a service account with the same privileges as mentioned for Cloud Run. In Kubernetes, you will need to set up [workload identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) so the DVT container can impersonate the service account.
|
|
485
|
+
|
|
486
|
+
In Cloud Run, the [job](https://cloud.google.com/run/docs/create-jobs) must be run as multiple, independent tasks with the task count set to the number of partitions generated. In Kubernetes, set the number of completions to the number of partitions generated - see [Kubernetes Parallel Jobs](https://kubernetes.io/docs/concepts/workloads/controllers/job/#parallel-jobs). The option `--kube-completions or -kc` tells DVT that many DVT containers are running in a Kubernetes cluster. Each DVT container only validates the specific partition yaml (based on the index assigned by Kubernetes control plane). If the `-kc` option is used and you are not running in indexed mode, you will receive a warning and the container will process all the validations sequentially. If the `-kc` option is used and a config directory is not provided (a `--config-file` is provided instead), a warning is issued.
|
|
487
|
+
|
|
488
|
+
By default, each partition validation is retried up to 3 times if there is an error. In Kubernetes and Cloud Run, you can set the parallelism to the number you want. Keep in mind that if you are validating 1000's of partitions in parallel, you may find that setting the parallelism too high (say 100) may result in timeouts and slow down the validation.
|
|
449
489
|
|
|
450
490
|
### Validation Reports
|
|
451
491
|
|
|
@@ -602,7 +642,7 @@ significant figure.
|
|
|
602
642
|
|
|
603
643
|
Once a calculated field is defined, it can be referenced by other calculated
|
|
604
644
|
fields at any "depth" or higher. Depth controls how many subqueries are executed
|
|
605
|
-
in the resulting query. For example, with the following YAML config
|
|
645
|
+
in the resulting query. For example, with the following YAML config:
|
|
606
646
|
|
|
607
647
|
```yaml
|
|
608
648
|
- calculated_fields:
|
|
@@ -623,7 +663,7 @@ in the resulting query. For example, with the following YAML config...
|
|
|
623
663
|
depth: 1 # calculated one query above
|
|
624
664
|
```
|
|
625
665
|
|
|
626
|
-
is equivalent to the following SQL query
|
|
666
|
+
is equivalent to the following SQL query:
|
|
627
667
|
|
|
628
668
|
```sql
|
|
629
669
|
SELECT
|
{google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/__main__.py
RENAMED
|
@@ -45,13 +45,21 @@ LOG_LEVEL_MAP = {
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
def _get_arg_config_file(args):
|
|
48
|
-
"""Return String
|
|
48
|
+
"""Return String YAML config file path."""
|
|
49
49
|
if not args.config_file:
|
|
50
50
|
raise ValueError("YAML Config File was not supplied.")
|
|
51
51
|
|
|
52
52
|
return args.config_file
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
def _get_arg_config_file_json(args):
|
|
56
|
+
"""Return String JSON config file path."""
|
|
57
|
+
if not args.config_file_json:
|
|
58
|
+
raise ValueError("JSON Config File was not supplied.")
|
|
59
|
+
|
|
60
|
+
return args.config_file_json
|
|
61
|
+
|
|
62
|
+
|
|
55
63
|
def get_aggregate_config(args, config_manager: ConfigManager):
|
|
56
64
|
"""Return list of formated aggregation objects.
|
|
57
65
|
|
|
@@ -235,7 +243,6 @@ def build_config_from_args(args: Namespace, config_manager: ConfigManager):
|
|
|
235
243
|
|
|
236
244
|
# For custom-query row command
|
|
237
245
|
if args.custom_query_type == consts.ROW_VALIDATION.lower():
|
|
238
|
-
|
|
239
246
|
# Append Comparison fields
|
|
240
247
|
if args.comparison_fields is not None:
|
|
241
248
|
comparison_fields = cli_tools.get_arg_list(
|
|
@@ -267,7 +274,6 @@ def build_config_from_args(args: Namespace, config_manager: ConfigManager):
|
|
|
267
274
|
|
|
268
275
|
# Append ROW_VALIDATION configs
|
|
269
276
|
if config_manager.validation_type == consts.ROW_VALIDATION:
|
|
270
|
-
|
|
271
277
|
# Append calculated fields: --hash/--concat
|
|
272
278
|
config_manager.append_calculated_fields(
|
|
273
279
|
get_calculated_config(args, config_manager)
|
|
@@ -314,14 +320,51 @@ def build_config_managers_from_args(
|
|
|
314
320
|
|
|
315
321
|
|
|
316
322
|
def config_runner(args):
|
|
323
|
+
"""Config Runner is where the decision is made to run validations from one or more files.
|
|
324
|
+
One file can produce multiple validations - for example when more than one set of tables are being validated
|
|
325
|
+
between the source and target. If multiple files are to be run and if the associated configuration files
|
|
326
|
+
are numbered sequentially, say from '0000.yaml' to '0012.yaml' (for 13 validations),
|
|
327
|
+
it is possible to run them concurrently in a Kubernetes / Cloud Run environment.
|
|
328
|
+
If the user wants that, they need to specify a -kc or --kube-completions which tells
|
|
329
|
+
DVT to only run the validation corresponding to the index number provided in the
|
|
330
|
+
JOB_COMPLETION_INDEX (for Kubernetes) or CLOUD_RUN_TASK_INDEX (for Cloud Run) environment
|
|
331
|
+
variable. This environment variable is set by the Kubernetes/Cloud Run container orchestrator.
|
|
332
|
+
The orchestrator spins up containers to complete each validation, one at a time.
|
|
333
|
+
"""
|
|
317
334
|
if args.config_dir:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
335
|
+
if args.kube_completions and (
|
|
336
|
+
("JOB_COMPLETION_INDEX" in os.environ.keys())
|
|
337
|
+
or ("CLOUD_RUN_TASK_INDEX" in os.environ.keys())
|
|
338
|
+
):
|
|
339
|
+
# Running in Kubernetes in Job completions - only run the yaml file corresponding to index
|
|
340
|
+
job_index = (
|
|
341
|
+
int(os.environ.get("JOB_COMPLETION_INDEX"))
|
|
342
|
+
if "JOB_COMPLETION_INDEX" in os.environ.keys()
|
|
343
|
+
else int(os.environ.get("CLOUD_RUN_TASK_INDEX"))
|
|
344
|
+
)
|
|
345
|
+
config_file_path = (
|
|
346
|
+
f"{args.config_dir}{job_index:04d}.yaml"
|
|
347
|
+
if args.config_dir.endswith("/")
|
|
348
|
+
else f"{args.config_dir}/{job_index:04d}.yaml"
|
|
349
|
+
)
|
|
350
|
+
setattr(args, "config_dir", None)
|
|
351
|
+
setattr(args, "config_file", config_file_path)
|
|
352
|
+
config_managers = build_config_managers_from_yaml(args, config_file_path)
|
|
353
|
+
else:
|
|
354
|
+
if args.kube_completions:
|
|
355
|
+
logging.warning(
|
|
356
|
+
"--kube-completions or -kc specified, however not running in Kubernetes Job completion, check your command line."
|
|
357
|
+
)
|
|
358
|
+
mgr = state_manager.StateManager(file_system_root_path=args.config_dir)
|
|
359
|
+
config_file_names = mgr.list_validations_in_dir(args.config_dir)
|
|
360
|
+
config_managers = []
|
|
361
|
+
for file in config_file_names:
|
|
362
|
+
config_managers.extend(build_config_managers_from_yaml(args, file))
|
|
324
363
|
else:
|
|
364
|
+
if args.kube_completions:
|
|
365
|
+
logging.warning(
|
|
366
|
+
"--kube-completions or -kc specified, which requires a config directory, however a specific config file is provided."
|
|
367
|
+
)
|
|
325
368
|
config_file_path = _get_arg_config_file(args)
|
|
326
369
|
config_managers = build_config_managers_from_yaml(args, config_file_path)
|
|
327
370
|
|
|
@@ -454,6 +497,26 @@ def convert_config_to_yaml(args, config_managers):
|
|
|
454
497
|
return yaml_config
|
|
455
498
|
|
|
456
499
|
|
|
500
|
+
def convert_config_to_json(config_managers) -> dict:
|
|
501
|
+
"""Return dict objects formatted for json validations.
|
|
502
|
+
JSON configs correspond to ConfigManager objects and therefore can only correspond to
|
|
503
|
+
one table validation.
|
|
504
|
+
|
|
505
|
+
Args:
|
|
506
|
+
config_managers (list[ConfigManager]): List of config manager instances.
|
|
507
|
+
"""
|
|
508
|
+
|
|
509
|
+
if len(config_managers) > 1:
|
|
510
|
+
raise ValueError(
|
|
511
|
+
"JSON configs can only be created for single table validations."
|
|
512
|
+
)
|
|
513
|
+
config_manager = config_managers[0]
|
|
514
|
+
json_config = config_manager.config
|
|
515
|
+
json_config[consts.CONFIG_SOURCE_CONN] = config_manager.get_source_connection()
|
|
516
|
+
json_config[consts.CONFIG_TARGET_CONN] = config_manager.get_target_connection()
|
|
517
|
+
return json_config
|
|
518
|
+
|
|
519
|
+
|
|
457
520
|
def run_validation(config_manager, dry_run=False, verbose=False):
|
|
458
521
|
"""Run a single validation.
|
|
459
522
|
|
|
@@ -517,7 +580,7 @@ def run_validations(args, config_managers):
|
|
|
517
580
|
for config_manager in config_managers:
|
|
518
581
|
if config_manager.config and consts.CONFIG_FILE in config_manager.config:
|
|
519
582
|
logging.info(
|
|
520
|
-
"Currently running the validation for
|
|
583
|
+
"Currently running the validation for YAML file: %s",
|
|
521
584
|
config_manager.config[consts.CONFIG_FILE],
|
|
522
585
|
)
|
|
523
586
|
try:
|
|
@@ -545,6 +608,17 @@ def store_yaml_config_file(args, config_managers):
|
|
|
545
608
|
cli_tools.store_validation(config_file_path, yaml_configs)
|
|
546
609
|
|
|
547
610
|
|
|
611
|
+
def store_json_config_file(args, config_managers):
|
|
612
|
+
"""Build a JSON config file from the supplied configs.
|
|
613
|
+
|
|
614
|
+
Args:
|
|
615
|
+
config_managers (list[ConfigManager]): List of config manager instances.
|
|
616
|
+
"""
|
|
617
|
+
json_config = convert_config_to_json(config_managers)
|
|
618
|
+
config_file_path = _get_arg_config_file_json(args)
|
|
619
|
+
cli_tools.store_validation_json(config_file_path, json_config)
|
|
620
|
+
|
|
621
|
+
|
|
548
622
|
def partition_and_store_config_files(args: Namespace) -> None:
|
|
549
623
|
"""Build multiple YAML Config files using user specified partition logic
|
|
550
624
|
|
|
@@ -562,7 +636,7 @@ def partition_and_store_config_files(args: Namespace) -> None:
|
|
|
562
636
|
|
|
563
637
|
def run(args) -> None:
|
|
564
638
|
"""Splits execution into:
|
|
565
|
-
1. Build and save single
|
|
639
|
+
1. Build and save single Config file (YAML or JSON)
|
|
566
640
|
2. Run Validations
|
|
567
641
|
|
|
568
642
|
Args:
|
|
@@ -574,6 +648,8 @@ def run(args) -> None:
|
|
|
574
648
|
config_managers = build_config_managers_from_args(args)
|
|
575
649
|
if args.config_file:
|
|
576
650
|
store_yaml_config_file(args, config_managers)
|
|
651
|
+
elif args.config_file_json:
|
|
652
|
+
store_json_config_file(args, config_managers)
|
|
577
653
|
else:
|
|
578
654
|
run_validations(args, config_managers)
|
|
579
655
|
|
{google-pso-data-validator-4.3.0 → google-pso-data-validator-4.4.0}/data_validation/cli_tools.py
RENAMED
|
@@ -74,6 +74,7 @@ CONNECTION_SOURCE_FIELDS = {
|
|
|
74
74
|
["user", "User used to connect"],
|
|
75
75
|
["password", "Password for supplied user"],
|
|
76
76
|
["database", "Database to connect to"],
|
|
77
|
+
["url", "Oracle SQLAlchemy connection URL"],
|
|
77
78
|
],
|
|
78
79
|
"MSSQL": [
|
|
79
80
|
["host", "Desired SQL Server host (default localhost)"],
|
|
@@ -99,18 +100,18 @@ CONNECTION_SOURCE_FIELDS = {
|
|
|
99
100
|
["connect_args", "(Optional) Additional connection arg mapping"],
|
|
100
101
|
],
|
|
101
102
|
"Postgres": [
|
|
102
|
-
["host", "Desired
|
|
103
|
-
["port", "
|
|
103
|
+
["host", "Desired PostgreSQL host."],
|
|
104
|
+
["port", "PostgreSQL port to connect on (e.g. 5432)"],
|
|
104
105
|
["user", "Username to connect to"],
|
|
105
106
|
["password", "Password for authentication of user"],
|
|
106
|
-
["database", "Database in
|
|
107
|
+
["database", "Database in PostgreSQL to connect to (default postgres)"],
|
|
107
108
|
],
|
|
108
109
|
"Redshift": [
|
|
109
|
-
["host", "Desired
|
|
110
|
-
["port", "
|
|
110
|
+
["host", "Desired Redshift host."],
|
|
111
|
+
["port", "Redshift port to connect on (e.g. 5439)"],
|
|
111
112
|
["user", "Username to connect to"],
|
|
112
113
|
["password", "Password for authentication of user"],
|
|
113
|
-
["database", "Database in
|
|
114
|
+
["database", "Database in Redshift to connect to"],
|
|
114
115
|
],
|
|
115
116
|
"Spanner": [
|
|
116
117
|
["project_id", "GCP Project to use for Spanner"],
|
|
@@ -125,7 +126,7 @@ CONNECTION_SOURCE_FIELDS = {
|
|
|
125
126
|
],
|
|
126
127
|
"Impala": [
|
|
127
128
|
["host", "Desired Impala host"],
|
|
128
|
-
["port", "Desired
|
|
129
|
+
["port", "Desired Impala port (10000 if not provided)"],
|
|
129
130
|
["database", "Desired Impala database (default if not provided)"],
|
|
130
131
|
["auth_mechanism", "Desired Impala auth mechanism (PLAIN if not provided)"],
|
|
131
132
|
[
|
|
@@ -320,7 +321,7 @@ def _configure_raw_query(subparsers):
|
|
|
320
321
|
|
|
321
322
|
|
|
322
323
|
def _configure_validation_config_parser(subparsers):
|
|
323
|
-
"""Configure arguments to run a data validation YAML config."""
|
|
324
|
+
"""Configure arguments to run a data validation YAML config file."""
|
|
324
325
|
validation_config_parser = subparsers.add_parser(
|
|
325
326
|
"configs", help="Run validations stored in a YAML config file"
|
|
326
327
|
)
|
|
@@ -347,6 +348,12 @@ def _configure_validation_config_parser(subparsers):
|
|
|
347
348
|
"-cdir",
|
|
348
349
|
help="Directory path containing YAML Config Files to be used for running validations.",
|
|
349
350
|
)
|
|
351
|
+
run_parser.add_argument(
|
|
352
|
+
"--kube-completions",
|
|
353
|
+
"-kc",
|
|
354
|
+
action="store_true",
|
|
355
|
+
help="When validating multiple table partitions generated by generate-table-partitions, using DVT in Kubernetes in index completion mode use this flag so that all the validations are completed",
|
|
356
|
+
)
|
|
350
357
|
|
|
351
358
|
get_parser = configs_subparsers.add_parser(
|
|
352
359
|
"get", help="Get and print a validation config"
|
|
@@ -395,8 +402,9 @@ def _configure_database_specific_parsers(parser):
|
|
|
395
402
|
raw_parser.add_argument("--json", "-j", help="Json string config")
|
|
396
403
|
|
|
397
404
|
for database in CONNECTION_SOURCE_FIELDS:
|
|
405
|
+
article = "an" if database[0].lower() in "aeiou" else "a"
|
|
398
406
|
db_parser = subparsers.add_parser(
|
|
399
|
-
database, help=f"Store
|
|
407
|
+
database, help=f"Store {article} {database} connection"
|
|
400
408
|
)
|
|
401
409
|
|
|
402
410
|
for field_obj in CONNECTION_SOURCE_FIELDS[database]:
|
|
@@ -914,7 +922,12 @@ def _add_common_arguments(optional_arguments, required_arguments):
|
|
|
914
922
|
optional_arguments.add_argument(
|
|
915
923
|
"--config-file",
|
|
916
924
|
"-c",
|
|
917
|
-
help="Store the validation in the YAML
|
|
925
|
+
help="Store the validation config in the YAML File Path specified",
|
|
926
|
+
)
|
|
927
|
+
optional_arguments.add_argument(
|
|
928
|
+
"--config-file-json",
|
|
929
|
+
"-cj",
|
|
930
|
+
help="Store the validation config in the JSON File Path specified to be used for application use cases",
|
|
918
931
|
)
|
|
919
932
|
optional_arguments.add_argument(
|
|
920
933
|
"--format",
|
|
@@ -1066,6 +1079,12 @@ def store_validation(validation_file_name, yaml_config):
|
|
|
1066
1079
|
mgr.create_validation_yaml(validation_file_name, yaml_config)
|
|
1067
1080
|
|
|
1068
1081
|
|
|
1082
|
+
def store_validation_json(validation_file_name, json_config):
|
|
1083
|
+
"""Store the validation JSON config under the given name."""
|
|
1084
|
+
mgr = state_manager.StateManager()
|
|
1085
|
+
mgr.create_validation_json(validation_file_name, json_config)
|
|
1086
|
+
|
|
1087
|
+
|
|
1069
1088
|
def store_partition(target_file_path, yaml_config, target_folder_path=None):
|
|
1070
1089
|
"""Store the partition YAML config under the given name."""
|
|
1071
1090
|
mgr = state_manager.StateManager(target_folder_path)
|