Skip to content

Commit 9c9912d

Browse files
committed
Allow row_filter_id and row_filter_ids both
1 parent e5c9c9c commit 9c9912d

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
@@ -92,14 +92,22 @@ def from_dict(
9292
)
9393
if column_id:
9494
column_id.upper()
95-
row_filter_ids: list[str] = get_from_dict_and_assert(
95+
row_filter_config: dict = get_keys_from_dict_and_assert_oneof(
9696
config_id=rule_binding_id,
9797
kwargs=kwargs,
98-
key="row_filter_ids",
99-
assertion=lambda x: type(x) == list,
100-
error_msg=f"Rule Binding ID: '{rule_binding_id}' must have defined value "
101-
f"'row_filter_ids' of type 'list'.",
98+
keys=["row_filter_id", "row_filter_ids"]
10299
)
100+
row_filter_ids = []
101+
if "row_filter_id" in row_filter_config:
102+
row_filter_ids.append(row_filter_config["row_filter_id"].upper())
103+
if "row_filter_ids" in row_filter_config:
104+
for row_filter in row_filter_config["row_filter_ids"]:
105+
if type(row_filter) == str:
106+
row_filter_ids.append(row_filter.upper())
107+
if type(row_filter) == dict:
108+
row_filter_ids.extend(
109+
[id.upper() for id in row_filter]
110+
)
103111
rule_ids: list[str] = get_from_dict_and_assert(
104112
config_id=rule_binding_id,
105113
kwargs=kwargs,
@@ -262,9 +270,9 @@ def resolve_row_filter_config_list(
262270
if len(row_filter) > 1:
263271
raise ValueError(
264272
f"Rule Binding {self.rule_binding_id} has "
265-
f"invalid configs in rule_ids. "
273+
f"invalid configs in row_filter_ids. "
266274
f"Each nested row_filter_id objects cannot "
267-
f"have more than one rule_id. "
275+
f"have more than one row_filter_id. "
268276
f"Current value: \n {row_filter}"
269277
)
270278
else:
@@ -273,7 +281,7 @@ def resolve_row_filter_config_list(
273281
else:
274282
row_filter_id = row_filter
275283
arguments = None
276-
row_filter_config = configs_cache.get_row_filter_id(row_filter_id.upper())
284+
row_filter_config = configs_cache.get_row_filter_id(row_filter_id)
277285
row_filter_config.resolve_sql_expr(arguments)
278286
resolved_row_filter_config_list.append(row_filter_config)
279287
assert_not_none_or_empty(

0 commit comments

Comments
 (0)