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, _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 Args: _context: Provide SparkExpectationsContext _df_dq: Input dataframe on which data quality rules need to be applied _input_count: input dataset count _error_count: error count in the dataset _output_count: output count in the dataset _rule_type: type of rule expectations _row_dq_flag: Mark it as True when dq running for row level expectations _source_agg_dq_flag: Mark it as True when dq running for agg level expectations on source dataframe _final_agg_dq_flag: Mark it as True when dq running for agg level expectations on final dataframe _source_query_dq_flag: Mark it as True when dq running for query level expectations on source dataframe _final_query_dq_flag: Mark it as True when dq running for query level expectations on final dataframe Returns: 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) -> Optional[List[Dict[str, str]]]
staticmethod
¶
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 |
Returns: Array of tuple with expectations rule properties
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 |
---|---|---|---|
_context |
SparkExpectationsContext
|
SparkExpectationsContext class object |
required |
rule |
dict
|
dict with rule properties |
required |
_rule_type_name |
str
|
which determines the type of the rule |
required |
_source_dq_enabled |
bool
|
Mark it as True when dq running for source dataframe |
False
|
_target_dq_enabled |
bool
|
Mark it as True when dq running for target dataframe |
False
|
Returns:
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 |
_source_dq_enabled |
bool
|
Mark it as True when dq running for source dataframe |
False
|
_target_dq_enabled |
bool
|
Mark it as True when dq running for target dataframe |
False
|
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
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 223 224 225 226 227 228 |
|