Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(low-code CDK): fix checkpointing for declarative streams #177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions airbyte_cdk/sources/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ def read( # type: ignore # ignoring typing for ConnectorStateManager because o
record_counter += 1

checkpoint_interval = self.state_checkpoint_interval
checkpoint = checkpoint_reader.get_checkpoint()
if (
should_checkpoint
and checkpoint_interval
and record_counter % checkpoint_interval == 0
and checkpoint is not None
):
airbyte_state_message = self._checkpoint_state(
checkpoint, state_manager=state_manager
)
yield airbyte_state_message
checkpoint = checkpoint_reader.get_checkpoint()
if checkpoint:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why moving checkpoint_reader.get_checkpoint() into the top level condition fixes the issue since all the above conditions are ands. I do see that we go from checkpoint is not None to just checkpoint. That seems like the part that would affect things.

Would we be able to simplify this to keep using just one condition as:

checkpoint = checkpoint_reader.get_checkpoint()
if (
  should_checkpoint
  and checkpoint_interval
  and record_counter % checkpoint_interval == 0
  and checkpoint
):

I didn't see anything in get_checkpoint() that requires it be called within the first conditional

airbyte_state_message = self._checkpoint_state(
checkpoint, state_manager=state_manager
)
yield airbyte_state_message

if internal_config.is_limit_reached(record_counter):
break
Expand Down
Loading