Skip to content

Commit bd9a59c

Browse files
committed
Done with creator
1 parent dff2bb0 commit bd9a59c

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

pyatlan/model/assets/core/alpha__d_q_rule.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def custom_sql_creator(
7474
dimension=dimension,
7575
custom_sql=custom_sql,
7676
description=description,
77-
column_qualified_name=None,
77+
column=None,
7878
threshold_unit=None,
7979
)
8080
return cls(attributes=attributes)
@@ -104,7 +104,7 @@ def table_level_rule_creator(
104104
threshold_value=threshold_value,
105105
alert_priority=alert_priority,
106106
rule_name=None,
107-
column_qualified_name=None,
107+
column=None,
108108
threshold_unit=None,
109109
dimension=None,
110110
custom_sql=None,
@@ -120,22 +120,22 @@ def column_level_rule_creator(
120120
client:AtlanClient,
121121
rule_type: str,
122122
asset: Asset,
123-
column_qualified_name: str,
123+
column: Asset,
124124
threshold_compare_operator: alpha_DQRuleThresholdCompareOperator,
125125
threshold_value: float,
126126
alert_priority: alpha_DQRuleAlertPriority,
127127
threshold_unit: Optional[alpha_DQRuleThresholdUnit] = None,
128128
) -> alpha_DQRule:
129129
validate_required_fields(
130-
["rule_type", "asset", "column_qualified_name", "threshold_compare_operator", "threshold_value", "alert_priority"],
131-
[rule_type, asset, column_qualified_name, threshold_compare_operator, threshold_value, alert_priority],
130+
["rule_type", "asset", "column", "threshold_compare_operator", "threshold_value", "alert_priority"],
131+
[rule_type, asset, column, threshold_compare_operator, threshold_value, alert_priority],
132132
)
133133

134134
attributes = alpha_DQRule.Attributes.creator(
135135
client=client,
136136
rule_type=rule_type,
137137
asset=asset,
138-
column_qualified_name=column_qualified_name,
138+
column=column,
139139
threshold_compare_operator=threshold_compare_operator,
140140
threshold_value=threshold_value,
141141
alert_priority=alert_priority,
@@ -824,7 +824,7 @@ def _generate_config_arguments_raw(
824824
compare_operator: alpha_DQRuleThresholdCompareOperator,
825825
threshold_value: float,
826826
threshold_unit: Optional[alpha_DQRuleThresholdUnit] = None,
827-
column_qualified_name: Optional[str] = None,
827+
column: Optional[Asset] = None,
828828
dq_priority: alpha_DQRuleAlertPriority,
829829
description: Optional[str] = None
830830
) -> str:
@@ -839,8 +839,8 @@ def _generate_config_arguments_raw(
839839
"alpha_dqRuleTemplateAdvancedSettings.dqPriority": dq_priority,
840840
}
841841

842-
if column_qualified_name is not None:
843-
config["alpha_dqRuleTemplateConfigBaseColumnQualifiedName"] = column_qualified_name
842+
if column is not None:
843+
config["alpha_dqRuleTemplateConfigBaseColumnQualifiedName"] = column.qualified_name
844844

845845
if description is not None:
846846
config["alpha_dqRuleTemplateConfigUserDescription"] = description
@@ -890,7 +890,7 @@ def creator(
890890
threshold_compare_operator: alpha_DQRuleThresholdCompareOperator,
891891
threshold_value: float,
892892
alert_priority: alpha_DQRuleAlertPriority,
893-
column_qualified_name: Optional[str] = None,
893+
column: Optional[Asset] = None,
894894
threshold_unit: Optional[alpha_DQRuleThresholdUnit] = None,
895895
dimension: Optional[alpha_DQDimension] = None,
896896
custom_sql: Optional[str] = None,
@@ -907,8 +907,10 @@ def creator(
907907
.include_on_results(alpha_DQRuleTemplate.ALPHADQ_RULE_TEMPLATE_DIMENSION)
908908
.include_on_results(alpha_DQRuleTemplate.ALPHADQ_RULE_TEMPLATE_CONFIG)
909909
).to_request()
910+
present = False
910911
for result in client.asset.search(request):
911912
if result.display_name == rule_type:
913+
present = True
912914
template_rule_name = result.name
913915
template_qualified_name = result.qualified_name
914916

@@ -922,8 +924,9 @@ def creator(
922924
threshold_unit_field = properties.get('alpha_dqRuleTemplateConfigThresholdUnit', {})
923925
default_value = threshold_unit_field.get('default')
924926
threshold_unit = default_value
925-
# else:
926-
# raise ErrorCode.DQ_RULE_NOT_FOUND.exception_with_parameters(result.display_name)
927+
928+
if present == False:
929+
raise ErrorCode.DQ_RULE_NOT_FOUND.exception_with_parameters(rule_type)
927930

928931
config_arguments_raw = alpha_DQRule.Attributes._generate_config_arguments_raw(
929932
is_alert_enabled=True,
@@ -933,7 +936,7 @@ def creator(
933936
compare_operator=threshold_compare_operator,
934937
threshold_value=threshold_value,
935938
threshold_unit=threshold_unit,
936-
column_qualified_name = column_qualified_name,
939+
column = column,
937940
dq_priority=alert_priority,
938941
description=description,
939942
)
@@ -960,9 +963,9 @@ def creator(
960963
alpha_dq_rule_template=alpha_DQRuleTemplate.ref_by_qualified_name(qualified_name=template_qualified_name),
961964
)
962965

963-
if column_qualified_name is not None:
964-
attr_dq.alpha_dq_rule_base_column_qualified_name=column_qualified_name
965-
attr_dq.alpha_dq_rule_base_column=Column.ref_by_qualified_name(qualified_name=column_qualified_name)
966+
if column is not None:
967+
attr_dq.alpha_dq_rule_base_column_qualified_name=column.qualified_name
968+
attr_dq.alpha_dq_rule_base_column=column
966969

967970
if rule_type == "Custom SQL":
968971
attr_dq.alpha_dq_rule_custom_s_q_l = custom_sql

pyatlan/model/enums.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2978,4 +2978,7 @@ class alpha_DQSourceSyncStatus(str, Enum):
29782978
class alpha_DQRuleThresholdCompareOperator(str, Enum):
29792979
EQUAL = "EQ"
29802980
GREATER_THAN_EQUAL = "GTE"
2981-
LESS_THAN_EQUAL = "LTE"
2981+
LESS_THAN_EQUAL = "LTE"
2982+
BETWEEN = "BETWEEN"
2983+
GREATER_THAN = "GT"
2984+
LESS_THAN = "LT"

0 commit comments

Comments
 (0)