Classes¶
spark_expectations.utils.actions.SparkExpectationsActions
¶
This class implements/supports applying data quality rules on given dataframe and performing required action
Functions¶
action_on_rules(_context: SparkExpectationsContext, _df_dq: DataFrame, _table_name: str, _input_count: int, _error_count: int = 0, _output_count: int = 0, _rule_type: Optional[str] = None, _row_dq_flag: bool = False, _source_agg_dq_flag: bool = False, _final_agg_dq_flag: bool = False, _source_query_dq_flag: bool = False, _final_query_dq_flag: bool = False) -> DataFrame
staticmethod
¶
This function takes necessary action set by the user on the rules and returns the dataframe with results
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_context |
SparkExpectationsContext
|
Provide SparkExpectationsContext |
required |
_df_dq |
DataFrame
|
Input dataframe on which data quality rules need to be applied |
required |
table_name |
error table name |
required | |
_input_count |
int
|
input dataset count |
required |
_error_count |
int
|
error count in the dataset |
0
|
_output_count |
int
|
output count in the dataset |
0
|
_rule_type |
Optional[str]
|
type of rule expectations |
None
|
_row_dq_flag |
bool
|
Mark it as True when dq running for row level expectations |
False
|
_source_agg_dq_flag |
bool
|
Mark it as True when dq running for agg level expectations on source dataframe |
False
|
_final_agg_dq_flag |
bool
|
Mark it as True when dq running for agg level expectations on final dataframe |
False
|
_source_query_dq_flag |
bool
|
Mark it as True when dq running for query level expectations on source dataframe |
False
|
_final_query_dq_flag |
bool
|
Mark it as True when dq running for query level expectations on final dataframe |
False
|
_action_on |
perform action on different stages in dq |
required | |
_source_agg_dq_result |
source aggregated data quality result |
required | |
_final_agg_dq_result |
final aggregated data quality result |
required | |
_source_query_dq_result |
source query based data quality result |
required | |
_final_query_dq_result |
final query based data quality result |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Returns a dataframe after dropping the error from the dataset |
Source code in spark_expectations/utils/actions.py
create_agg_dq_results(_context: SparkExpectationsContext, _df: DataFrame, _rule_type_name: str) -> List[Dict[str, str]]
¶
This function helps to collect the aggregation results in to the list Args: _context: SparkContext object _df: dataframe which contains agg data quality results _rule_type_name: which determines the type of the rule
Returns: List with dict of agg rules property name and value
Source code in spark_expectations/utils/actions.py
create_rules_map(_rule_map: Dict[str, str]) -> Any
staticmethod
¶
This function helps to extract the selected rules properties and returns array of dict with key and value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_rule_map |
Dict[str, str]
|
dict with rules properties |
required |
Source code in spark_expectations/utils/actions.py
get_rule_is_active(_context: SparkExpectationsContext, rule: dict, _rule_type_name: str, _source_dq_enabled: bool = False, _target_dq_enabled: bool = False) -> bool
staticmethod
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule |
dict
|
|
required |
_rule_tye_name |
|
required | |
_source_dq_enabled |
bool
|
|
False
|
_target_dq_enabled |
bool
|
|
False
|
Source code in spark_expectations/utils/actions.py
run_dq_rules(_context: SparkExpectationsContext, df: DataFrame, expectations: Dict[str, List[dict]], rule_type: str, _source_dq_enabled: bool = False, _target_dq_enabled: bool = False) -> DataFrame
staticmethod
¶
This function builds the expressions for the data quality rules and returns the dataframe with results
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_context |
SparkExpectationsContext
|
Provide SparkExpectationsContext |
required |
df |
DataFrame
|
Input dataframe on which data quality rules need to be applied |
required |
expectations |
Dict[str, List[dict]]
|
Provide the dict which has all the rules |
required |
rule_type |
str
|
identifier for the type of rule to be applied in processing |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Returns a dataframe with all the rules run the input dataframe |
Source code in spark_expectations/utils/actions.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|