Skip to content

Commit

Permalink
Low-Code CDK: make RecordFilter.filter_records as generator (#24772)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr committed Apr 3, 2023
1 parent 2905019 commit 032f9b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ def filter_records(
next_page_token: Optional[Mapping[str, Any]] = None,
) -> List[Record]:
kwargs = {"stream_state": stream_state, "stream_slice": stream_slice, "next_page_token": next_page_token}
return [record for record in records if self._filter_interpolator.eval(self.config, record=record, **kwargs)]
for record in records:
if self._filter_interpolator.eval(self.config, record=record, **kwargs):
yield record
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def test_record_filter(test_name, filter_template, records, expected_records):
actual_records = record_filter.filter_records(
records, stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token
)
assert actual_records == expected_records
assert list(actual_records) == expected_records
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_record_filter(test_name, field_path, filter_template, body, expected_re
actual_records = record_selector.select_records(
response=response, stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token
)
assert actual_records == expected_records
assert list(actual_records) == expected_records


def create_response(body):
Expand Down

0 comments on commit 032f9b8

Please sign in to comment.