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(taps): Use recent start_date as starting_replication_value #759

Merged
merged 19 commits into from
Aug 23, 2022
Merged
Changes from 6 commits
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
16 changes: 14 additions & 2 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,20 @@ def _write_starting_replication_value(self, context: Optional[dict]) -> None:
):
value = replication_key_value

elif "start_date" in self.config:
value = self.config["start_date"]
# Use start_date if it is more recent than the replication_key state
if "start_date" in self.config:
if not value:
value = self.config["start_date"]
else:
value_datetime = cast(datetime.datetime, pendulum.parse(value))
start_datetime = cast(
datetime.datetime, pendulum.parse(self.config["start_date"])
)
edgarrmondragon marked this conversation as resolved.
Show resolved Hide resolved
value = (
value
if value_datetime > start_datetime
else self.config["start_date"]
)

write_starting_replication_value(state, value)

Expand Down