Tasks
Collection of tasks that can be used to run Data Quality checks using Soda Core.
soda_scan_execute(data_source_name, configuration, checks, variables, scan_results_file=None, verbose=False, return_scan_result_file_content=False, shell_env=None)
async
Task that execute a Soda Scan. First, the scan is created and configured using the provided configuration, checks, and other options, and then it is executed against the provided data source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_source_name |
str
|
The name of the data source against
which the checks will be executed. The data source name
must match one of the data sources provided in the
|
required |
configuration |
SodaConfiguration
|
|
required |
checks |
SodaCLCheck
|
|
required |
variables |
Optional[Dict[str, str]]
|
A |
required |
scan_results_file |
Optional[str]
|
The path to the file where the scan results will be stored. If not provided, the scan results will not be stored on the file system and only the stdout of the soda shell task would be returned. |
None
|
verbose |
bool
|
Whether to run the checks with a verbose log or not.
Default to |
False
|
return_scan_result_file_content |
bool
|
Controls the return of the task.
If |
False
|
shell_env |
Optional[Dict[str, str]]
|
A |
None
|
Returns:
Type | Description |
---|---|
Union[List, str]
|
Logs produced by running |
Example
from prefect_soda_core.sodacl_check import SodaCLCheck
from prefect_soda_core.soda_configuration import SodaConfiguration
from prefect_soda_core.tasks import soda_scan_execute
from prefect import flow
sodacl_check_block = SodaCLCheck.load("SODACL_CHECK_BLOCK_NAME")
soda_configuration_block = SodaConfiguration.load("SODA_CONF_BLOCK_NAME")
@flow
def run_soda_scan():
return soda_scan_execute(
data_source_name="datasource",
configuration=soda_configuration_block,
checks=sodacl_check_block,
variables={"key": "value"},
scan_results_file="scan_results.json",
verbose=False,
return_scan_result_file_content=False,
shell_env={"SNOWFLAKE_PASSWORD": "********"}
)
Source code in prefect_soda_core/tasks.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|