Skip to content

Commit 00cdb0a

Browse files
committed
Allow row_filter_id and row_filter_ids both
1 parent 089064c commit 00cdb0a

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

clouddq/classes/dq_rule_binding.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,22 @@ def from_dict(
9494
)
9595
if column_id:
9696
column_id.upper()
97-
row_filter_ids: list[str] = get_from_dict_and_assert(
97+
row_filter_config: dict = get_keys_from_dict_and_assert_oneof(
9898
config_id=rule_binding_id,
9999
kwargs=kwargs,
100-
key="row_filter_ids",
101-
assertion=lambda x: type(x) == list,
102-
error_msg=f"Rule Binding ID: '{rule_binding_id}' must have defined value "
103-
f"'row_filter_ids' of type 'list'.",
100+
keys=["row_filter_id", "row_filter_ids"]
104101
)
102+
row_filter_ids = []
103+
if "row_filter_id" in row_filter_config:
104+
row_filter_ids.append(row_filter_config["row_filter_id"].upper())
105+
if "row_filter_ids" in row_filter_config:
106+
for row_filter in row_filter_config["row_filter_ids"]:
107+
if type(row_filter) == str:
108+
row_filter_ids.append(row_filter.upper())
109+
if type(row_filter) == dict:
110+
row_filter_ids.extend(
111+
[id.upper() for id in row_filter]
112+
)
105113
rule_ids: list[str] = get_from_dict_and_assert(
106114
config_id=rule_binding_id,
107115
kwargs=kwargs,
@@ -269,9 +277,9 @@ def resolve_row_filter_config_list(
269277
if len(row_filter) > 1:
270278
raise ValueError(
271279
f"Rule Binding {self.rule_binding_id} has "
272-
f"invalid configs in rule_ids. "
280+
f"invalid configs in row_filter_ids. "
273281
f"Each nested row_filter_id objects cannot "
274-
f"have more than one rule_id. "
282+
f"have more than one row_filter_id. "
275283
f"Current value: \n {row_filter}"
276284
)
277285
else:
@@ -280,7 +288,7 @@ def resolve_row_filter_config_list(
280288
else:
281289
row_filter_id = row_filter
282290
arguments = None
283-
row_filter_config = configs_cache.get_row_filter_id(row_filter_id.upper())
291+
row_filter_config = configs_cache.get_row_filter_id(row_filter_id)
284292
row_filter_config.resolve_sql_expr(arguments)
285293
resolved_row_filter_config_list.append(row_filter_config)
286294
assert_not_none_or_empty(

0 commit comments

Comments
 (0)