|
1 | 1 |
|
2 | | - @classmethod |
| 2 | +@classmethod |
3 | 3 | @init_guid |
4 | 4 | def custom_sql_creator( |
5 | 5 | cls, |
|
137 | 137 | ], |
138 | 138 | ) |
139 | 139 | template_config = client.dq_template_config_cache.get_template_config(rule_type) |
140 | | - threshold_compare_operator = alpha_DQRule.Attributes._validate_template_features( |
141 | | - rule_type, |
142 | | - rule_conditions, |
143 | | - row_scope_filtering_enabled, |
144 | | - template_config, |
145 | | - threshold_compare_operator, |
| 140 | + |
| 141 | + asset_for_validation = asset |
| 142 | + if row_scope_filtering_enabled and asset.qualified_name: |
| 143 | + from pyatlan.model.fluent_search import FluentSearch |
| 144 | + |
| 145 | + search_request = ( |
| 146 | + FluentSearch() |
| 147 | + .where(Asset.QUALIFIED_NAME.eq(asset.qualified_name)) |
| 148 | + .include_on_results( |
| 149 | + Asset.ALPHAASSET_DQ_ROW_SCOPE_FILTER_COLUMN_QUALIFIED_NAME |
| 150 | + ) |
| 151 | + ).to_request() |
| 152 | + results = client.asset.search(search_request) |
| 153 | + if results.count == 1: |
| 154 | + asset_for_validation = results.current_page()[0] |
| 155 | + |
| 156 | + threshold_compare_operator = ( |
| 157 | + alpha_DQRule.Attributes._validate_template_features( |
| 158 | + rule_type, |
| 159 | + rule_conditions, |
| 160 | + row_scope_filtering_enabled, |
| 161 | + template_config, |
| 162 | + threshold_compare_operator, |
| 163 | + asset_for_validation, |
| 164 | + ) |
146 | 165 | ) |
147 | 166 |
|
148 | 167 | attributes = alpha_DQRule.Attributes.creator( |
|
222 | 241 | retrieved_column = search_result.alpha_dq_rule_base_column # type: ignore[attr-defined] |
223 | 242 | retrieved_alert_priority = search_result.alpha_dq_rule_alert_priority # type: ignore[attr-defined] |
224 | 243 | retrieved_row_scope_filtering_enabled = ( |
225 | | - search_result.alpha_dq_rule_row_scope_filtering_enabled |
226 | | - ) # type: ignore[attr-defined] |
| 244 | + search_result.alpha_dq_rule_row_scope_filtering_enabled # type: ignore[attr-defined] |
| 245 | + ) |
227 | 246 | retrieved_description = search_result.user_description |
228 | 247 | retrieved_asset = search_result.alpha_dq_rule_base_dataset # type: ignore[attr-defined] |
229 | 248 | retrieved_template_rule_name = search_result.alpha_dq_rule_template_name # type: ignore[attr-defined] |
|
254 | 273 | template_config = client.dq_template_config_cache.get_template_config( |
255 | 274 | retrieved_rule_type |
256 | 275 | ) |
257 | | - validated_threshold_operator = alpha_DQRule.Attributes._validate_template_features( |
258 | | - retrieved_rule_type, |
259 | | - rule_conditions, |
260 | | - row_scope_filtering_enabled, |
261 | | - template_config, |
262 | | - threshold_compare_operator or retrieved_threshold_compare_operator, |
| 276 | + validated_threshold_operator = ( |
| 277 | + alpha_DQRule.Attributes._validate_template_features( |
| 278 | + retrieved_rule_type, |
| 279 | + rule_conditions, |
| 280 | + row_scope_filtering_enabled, |
| 281 | + template_config, |
| 282 | + threshold_compare_operator or retrieved_threshold_compare_operator, |
| 283 | + retrieved_asset, |
| 284 | + ) |
| 285 | + ) |
| 286 | + |
| 287 | + final_compare_operator = ( |
| 288 | + validated_threshold_operator |
| 289 | + or threshold_compare_operator |
| 290 | + or retrieved_threshold_compare_operator |
263 | 291 | ) |
264 | 292 |
|
265 | 293 | config_arguments_raw = alpha_DQRule.Attributes._generate_config_arguments_raw( |
266 | 294 | is_alert_enabled=True, |
267 | 295 | custom_sql=custom_sql or retrieved_custom_sql, |
268 | 296 | display_name=rule_name or retrieved_rule_name, |
269 | 297 | dimension=dimension or retrieved_dimension, |
270 | | - compare_operator=validated_threshold_operator, |
| 298 | + compare_operator=final_compare_operator, |
271 | 299 | threshold_value=threshold_value or retrieved_threshold_value, |
272 | 300 | threshold_unit=threshold_unit or retrieved_threshold_unit, |
273 | 301 | column=retrieved_column, |
|
281 | 309 | name="", |
282 | 310 | alpha_dq_rule_config_arguments=alpha_DQRuleConfigArguments( |
283 | 311 | alpha_dq_rule_threshold_object=alpha_DQRuleThresholdObject( |
284 | | - alpha_dq_rule_threshold_compare_operator=validated_threshold_operator, |
| 312 | + alpha_dq_rule_threshold_compare_operator=final_compare_operator, |
285 | 313 | alpha_dq_rule_threshold_value=threshold_value |
286 | 314 | or retrieved_threshold_value, |
287 | 315 | alpha_dq_rule_threshold_unit=threshold_unit |
|
0 commit comments