1
0
mirror of synced 2026-01-06 06:04:16 -05:00

🐛 Python CDK: fix StopIteration error for check_availability (#20429)

This commit is contained in:
Baz
2022-12-13 17:54:49 +02:00
committed by GitHub
parent 81341d0f74
commit 4e9b014277
4 changed files with 38 additions and 5 deletions

View File

@@ -17,10 +17,13 @@ class StreamHelper:
:param stream: stream
:return: StreamData containing the first record in the stream
"""
# Some streams need a stream slice to read records (e.g. if they have a SubstreamSlicer)
stream_slice = self.get_stream_slice(stream)
records = stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice=stream_slice)
next(records)
try:
# Some streams need a stream slice to read records (e.g. if they have a SubstreamSlicer)
stream_slice = self.get_stream_slice(stream)
records = stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice=stream_slice)
return next(records)
except StopIteration:
return {}
@staticmethod
def get_stream_slice(stream: Stream) -> Optional[Mapping[str, Any]]: