Skip to content

Commit aa99d1b

Browse files
refactor(cdk): rename skip_slice to emit_slice for clarity
- Renamed skip_slice to emit_slice and inverted the logic - Now emit_slice=False by default, set to True when extraction succeeds - Makes the code more intuitive: we emit slices when conditions are met Co-Authored-By: Daryna Ishchenko <darina.ishchenko17@gmail.com>
1 parent 58ffd0d commit aa99d1b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def stream_slices(self) -> Iterable[StreamSlice]:
212212
for parent_record, is_last_record_in_slice in iterate_with_last_flag(
213213
partition.read()
214214
):
215-
skip_slice = True
215+
emit_slice = False
216216
if parent_record is not None:
217217
# In the previous CDK implementation, state management was done internally by the stream.
218218
# However, this could cause issues when doing availability check for example as the availability
@@ -234,12 +234,12 @@ def stream_slices(self) -> Iterable[StreamSlice]:
234234
record_data, # type: ignore [arg-type]
235235
parent_field,
236236
)
237+
emit_slice = True
237238
except KeyError:
238239
# FIXME a log here would go a long way for debugging
239240
pass
240-
else:
241-
skip_slice = False
242241

242+
if emit_slice:
243243
# Add extra fields
244244
extracted_extra_fields = self._extract_extra_fields(
245245
record_data, extra_fields
@@ -259,7 +259,7 @@ def stream_slices(self) -> Iterable[StreamSlice]:
259259
if is_last_slice:
260260
parent_stream.cursor.ensure_at_least_one_state_emitted()
261261

262-
if not skip_slice:
262+
if emit_slice:
263263
yield StreamSlice(
264264
partition={
265265
partition_field: partition_value,

0 commit comments

Comments
 (0)