@@ -61,6 +61,7 @@ def custom_sql_creator(
61
61
) -> alpha_DQRule :
62
62
validate_required_fields (
63
63
[
64
+ "client" ,
64
65
"rule_name" ,
65
66
"asset" ,
66
67
"threshold_compare_operator" ,
@@ -70,6 +71,7 @@ def custom_sql_creator(
70
71
"custom_sql" ,
71
72
],
72
73
[
74
+ client ,
73
75
rule_name ,
74
76
asset ,
75
77
threshold_compare_operator ,
@@ -110,13 +112,15 @@ def table_level_rule_creator(
110
112
) -> alpha_DQRule :
111
113
validate_required_fields (
112
114
[
115
+ "client" ,
113
116
"rule_type" ,
114
117
"asset" ,
115
118
"threshold_compare_operator" ,
116
119
"threshold_value" ,
117
120
"alert_priority" ,
118
121
],
119
122
[
123
+ client ,
120
124
rule_type ,
121
125
asset ,
122
126
threshold_compare_operator ,
@@ -159,6 +163,7 @@ def column_level_rule_creator(
159
163
) -> alpha_DQRule :
160
164
validate_required_fields (
161
165
[
166
+ "client" ,
162
167
"rule_type" ,
163
168
"asset" ,
164
169
"column" ,
@@ -167,6 +172,7 @@ def column_level_rule_creator(
167
172
"alert_priority" ,
168
173
],
169
174
[
175
+ client ,
170
176
rule_type ,
171
177
asset ,
172
178
column ,
@@ -212,8 +218,8 @@ def updater(
212
218
from pyatlan .model .fluent_search import FluentSearch
213
219
214
220
validate_required_fields (
215
- ["qualified_name" ],
216
- [qualified_name ],
221
+ ["client" , " qualified_name" ],
222
+ [client , qualified_name ],
217
223
)
218
224
request = (
219
225
FluentSearch ()
@@ -235,6 +241,11 @@ def updater(
235
241
236
242
results = client .asset .search (request )
237
243
244
+ if results .count != 1 :
245
+ raise ValueError (
246
+ f"Expected exactly 1 asset for qualified_name: { qualified_name } , "
247
+ f"but found: { results .count } "
248
+ )
238
249
search_result = results .current_page ()[0 ]
239
250
240
251
retrieved_custom_sql = search_result .alpha_dq_rule_custom_s_q_l # type: ignore[attr-defined]
@@ -246,9 +257,27 @@ def updater(
246
257
retrieved_asset = search_result .alpha_dq_rule_base_dataset # type: ignore[attr-defined]
247
258
retrieved_template_rule_name = search_result .alpha_dq_rule_template_name # type: ignore[attr-defined]
248
259
retrieved_template = search_result .alpha_dq_rule_template # type: ignore[attr-defined]
249
- retrieved_threshold_compare_operator = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_compare_operator # type: ignore[attr-defined]
250
- retrieved_threshold_value = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_value # type: ignore[attr-defined]
251
- retrieved_threshold_unit = search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_unit # type: ignore[attr-defined]
260
+ retrieved_threshold_compare_operator = (
261
+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_compare_operator # type: ignore[attr-defined]
262
+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
263
+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
264
+ is not None
265
+ else None
266
+ )
267
+ retrieved_threshold_value = (
268
+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_value # type: ignore[attr-defined]
269
+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
270
+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
271
+ is not None
272
+ else None
273
+ ) # type: ignore[attr-defined]
274
+ retrieved_threshold_unit = (
275
+ search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object .alpha_dq_rule_threshold_unit # type: ignore[attr-defined]
276
+ if search_result .alpha_dq_rule_config_arguments is not None # type: ignore[attr-defined]
277
+ and search_result .alpha_dq_rule_config_arguments .alpha_dq_rule_threshold_object # type: ignore[attr-defined]
278
+ is not None
279
+ else None
280
+ ) # type: ignore[attr-defined]
252
281
253
282
config_arguments_raw = alpha_DQRule .Attributes ._generate_config_arguments_raw (
254
283
is_alert_enabled = True ,
@@ -1053,30 +1082,32 @@ def creator(
1053
1082
custom_sql : Optional [str ] = None ,
1054
1083
description : Optional [str ] = None ,
1055
1084
) -> alpha_DQRule .Attributes :
1056
- template_config = client .template_config_cache .get_template_config (
1085
+ template_config = client .dq_template_config_cache .get_template_config (
1057
1086
rule_type
1058
1087
)
1059
1088
1060
1089
if template_config is None :
1061
1090
raise ErrorCode .DQ_RULE_NOT_FOUND .exception_with_parameters (rule_type )
1062
1091
1063
- template_rule_name = template_config [ "name" ]
1064
- template_qualified_name = template_config [ "qualified_name" ]
1092
+ template_rule_name = template_config . get ( "name" )
1093
+ template_qualified_name = template_config . get ( "qualified_name" )
1065
1094
1066
1095
if dimension is None :
1067
- dimension = template_config [ "dimension" ]
1096
+ dimension = template_config . get ( "dimension" )
1068
1097
1069
1098
if threshold_unit is None :
1070
- threashold_object = template_config [
1071
- "config"
1072
- ].alpha_dq_rule_template_config_threshold_object
1073
- threashold_object_json = json .loads (threashold_object )
1074
- properties = threashold_object_json .get ("properties" , {})
1075
- threshold_unit_field = properties .get (
1076
- "alpha_dqRuleTemplateConfigThresholdUnit" , {}
1077
- )
1078
- default_value = threshold_unit_field .get ("default" )
1079
- threshold_unit = default_value
1099
+ config = template_config .get ("config" )
1100
+ if config is not None :
1101
+ threashold_object = (
1102
+ config .alpha_dq_rule_template_config_threshold_object
1103
+ )
1104
+ threashold_object_json = json .loads (threashold_object )
1105
+ properties = threashold_object_json .get ("properties" , {})
1106
+ threshold_unit_field = properties .get (
1107
+ "alpha_dqRuleTemplateConfigThresholdUnit" , {}
1108
+ )
1109
+ default_value = threshold_unit_field .get ("default" )
1110
+ threshold_unit = default_value
1080
1111
1081
1112
config_arguments_raw = (
1082
1113
alpha_DQRule .Attributes ._generate_config_arguments_raw (
@@ -1112,7 +1143,7 @@ def creator(
1112
1143
alpha_dq_rule_dimension = dimension ,
1113
1144
alpha_dq_rule_template_name = template_rule_name ,
1114
1145
alpha_dq_rule_template = alpha_DQRuleTemplate .ref_by_qualified_name (
1115
- qualified_name = template_qualified_name
1146
+ qualified_name = template_qualified_name # type: ignore
1116
1147
),
1117
1148
)
1118
1149
0 commit comments