1919 DataQualityRuleAlertPriority ,
2020 DataQualityRuleCustomSQLReturnType ,
2121 DataQualityRuleStatus ,
22+ DataQualityRuleTemplateType ,
2223 DataQualityRuleThresholdCompareOperator ,
2324 DataQualityRuleThresholdUnit ,
2425 DataQualitySourceSyncStatus ,
@@ -88,7 +89,7 @@ def custom_sql_creator(
8889 attributes = DataQualityRule .Attributes .creator (
8990 client = client ,
9091 rule_name = rule_name ,
91- rule_type = "Custom SQL" ,
92+ rule_type = DataQualityRuleTemplateType . CUSTOM_SQL ,
9293 asset = asset ,
9394 threshold_compare_operator = threshold_compare_operator ,
9495 threshold_value = threshold_value ,
@@ -108,7 +109,7 @@ def table_level_rule_creator(
108109 cls ,
109110 * ,
110111 client : AtlanClient ,
111- rule_type : str ,
112+ rule_type : DataQualityRuleTemplateType ,
112113 asset : Asset ,
113114 threshold_compare_operator : DataQualityRuleThresholdCompareOperator ,
114115 threshold_value : int ,
@@ -156,7 +157,7 @@ def column_level_rule_creator(
156157 cls ,
157158 * ,
158159 client : AtlanClient ,
159- rule_type : str ,
160+ rule_type : DataQualityRuleTemplateType ,
160161 asset : Asset ,
161162 column : Asset ,
162163 threshold_value : int ,
@@ -186,7 +187,9 @@ def column_level_rule_creator(
186187 alert_priority ,
187188 ],
188189 )
189- template_config = client .dq_template_config_cache .get_template_config (rule_type )
190+ template_config = client .dq_template_config_cache .get_template_config (
191+ rule_type .value
192+ )
190193
191194 asset_for_validation , target_table_asset = (
192195 DataQualityRule .Attributes ._fetch_assets_for_row_scope_validation (
@@ -322,16 +325,20 @@ def updater(
322325 else None
323326 ) # type: ignore[attr-defined]
324327
325- retrieved_rule_type = retrieved_template_rule_name
326- template_config = client .dq_template_config_cache .get_template_config (
327- retrieved_rule_type
328- )
328+ template_config = None
329+ if retrieved_template_rule_name :
330+ template_config = client .dq_template_config_cache .get_template_config (
331+ retrieved_template_rule_name
332+ )
329333
330- final_rule_conditions = rule_conditions or (
331- search_result .dq_rule_config_arguments .dq_rule_config_rule_conditions # type: ignore[attr-defined]
332- if search_result .dq_rule_config_arguments is not None # type: ignore[attr-defined]
333- else None
334- )
334+ if rule_conditions :
335+ final_rule_conditions = rule_conditions
336+ elif search_result .dq_rule_config_arguments is not None : # type: ignore[attr-defined]
337+ final_rule_conditions = (
338+ search_result .dq_rule_config_arguments .dq_rule_config_rule_conditions # type: ignore[attr-defined]
339+ )
340+ else :
341+ final_rule_conditions = None
335342
336343 final_row_scope_filtering_enabled = (
337344 row_scope_filtering_enabled or retrieved_row_scope_filtering_enabled
@@ -348,17 +355,26 @@ def updater(
348355 else :
349356 target_table_asset = None
350357
351- validated_threshold_operator = (
352- DataQualityRule .Attributes ._validate_template_features (
353- retrieved_rule_type ,
354- final_rule_conditions ,
355- final_row_scope_filtering_enabled ,
356- template_config ,
357- threshold_compare_operator or retrieved_threshold_compare_operator ,
358- retrieved_asset ,
359- target_table_asset ,
360- )
361- )
358+ validated_threshold_operator = None
359+ if retrieved_template_rule_name and template_config :
360+ try :
361+ retrieved_rule_type = DataQualityRuleTemplateType (
362+ retrieved_template_rule_name
363+ )
364+ validated_threshold_operator = (
365+ DataQualityRule .Attributes ._validate_template_features (
366+ retrieved_rule_type ,
367+ final_rule_conditions ,
368+ final_row_scope_filtering_enabled ,
369+ template_config ,
370+ threshold_compare_operator
371+ or retrieved_threshold_compare_operator ,
372+ retrieved_asset ,
373+ target_table_asset ,
374+ )
375+ )
376+ except ValueError :
377+ pass
362378
363379 final_compare_operator = (
364380 validated_threshold_operator
@@ -1190,7 +1206,7 @@ def _get_template_config_value(
11901206
11911207 @staticmethod
11921208 def _validate_template_features (
1193- rule_type : str ,
1209+ rule_type : DataQualityRuleTemplateType ,
11941210 rule_conditions : Optional [str ],
11951211 row_scope_filtering_enabled : Optional [bool ],
11961212 template_config : Optional [dict ],
@@ -1210,7 +1226,7 @@ def _validate_template_features(
12101226 and config .dq_rule_template_config_rule_conditions is None
12111227 ):
12121228 raise ErrorCode .DQ_RULE_TYPE_NOT_SUPPORTED .exception_with_parameters (
1213- rule_type , "rule conditions"
1229+ rule_type . value , "rule conditions"
12141230 )
12151231
12161232 if row_scope_filtering_enabled :
@@ -1219,7 +1235,7 @@ def _validate_template_features(
12191235 )
12201236 if "dqRuleRowScopeFilteringEnabled" not in str (advanced_settings ):
12211237 raise ErrorCode .DQ_RULE_TYPE_NOT_SUPPORTED .exception_with_parameters (
1222- rule_type , "row scope filtering"
1238+ rule_type . value , "row scope filtering"
12231239 )
12241240
12251241 if asset and not getattr (
@@ -1340,7 +1356,7 @@ def creator(
13401356 * ,
13411357 client : AtlanClient ,
13421358 rule_name : str ,
1343- rule_type : str ,
1359+ rule_type : DataQualityRuleTemplateType ,
13441360 asset : Asset ,
13451361 threshold_compare_operator : DataQualityRuleThresholdCompareOperator ,
13461362 threshold_value : int ,
@@ -1355,11 +1371,13 @@ def creator(
13551371 row_scope_filtering_enabled : Optional [bool ] = False ,
13561372 ) -> DataQualityRule .Attributes :
13571373 template_config = client .dq_template_config_cache .get_template_config (
1358- rule_type
1374+ rule_type . value
13591375 )
13601376
13611377 if template_config is None :
1362- raise ErrorCode .DQ_RULE_NOT_FOUND .exception_with_parameters (rule_type )
1378+ raise ErrorCode .DQ_RULE_NOT_FOUND .exception_with_parameters (
1379+ rule_type .value
1380+ )
13631381
13641382 template_rule_name = template_config .get ("name" )
13651383 template_qualified_name = template_config .get ("qualified_name" )
0 commit comments