diff --git a/airbyte-integrations/connectors/source-twilio/source_twilio/streams.py b/airbyte-integrations/connectors/source-twilio/source_twilio/streams.py index 8a1c103079251..4974ef16c97b2 100644 --- a/airbyte-integrations/connectors/source-twilio/source_twilio/streams.py +++ b/airbyte-integrations/connectors/source-twilio/source_twilio/streams.py @@ -201,15 +201,13 @@ def read_records( stream_slice: Mapping[str, Any] = None, stream_state: Mapping[str, Any] = None, ) -> Iterable[Mapping[str, Any]]: - unsorted_records = [] + max_cursor = self.state.get(self.cursor_field, self._start_date) for record in super().read_records(sync_mode, cursor_field, stream_slice, stream_state): record[self.cursor_field] = pendulum.parse(record[self.cursor_field], strict=False).to_iso8601_string() - unsorted_records.append(record) - sorted_records = sorted(unsorted_records, key=lambda x: x[self.cursor_field]) - for record in sorted_records: - if record[self.cursor_field] >= self.state.get(self.cursor_field, self._start_date): - self._cursor_value = record[self.cursor_field] + max_cursor = max(max_cursor, record[self.cursor_field]) + if self.state.get(self.cursor_field, self._start_date) <= record[self.cursor_field]: yield record + self._cursor_value = max_cursor class TwilioNestedStream(TwilioStream):