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

✨ Source Mailchimp: Add optional start_date to config #32852

Merged
merged 42 commits into from
Dec 20, 2023

Conversation

ChristoGrab
Copy link
Contributor

@ChristoGrab ChristoGrab commented Nov 27, 2023

What

Adds an optional start_date to Source Mailchimp's config, to resolve customer request in #20814

How

  • If a start_date is provided by a user via config, incremental streams will compare it against the value found in the current stream slice's state, to determine which to use as a filter in the query params. If only one of these values exists, it will be used by default.
  • If no start_date is set by a user in the config and the slice's state is empty (ie first sync), the filtering query param is not added to the request, and all available data is fetched from the API.
  • The API endpoints for two of the existing incremental streams, Segment Members and Unsubscribes, do not support filtering by the cursor value in query params, and will always return all available data. For these streams, the same filtering logic takes place, except this occurs during the parsing of the response, before the records are read.

User Impact

No impact on current customers. The start_date in config is an optional input and defaults to None if left empty. Therefore, for users with existing connections, the currently existing logic resumes, whereby the connector always fetches and reads all available data during first sync.

ChristoGrab and others added 19 commits November 16, 2023 08:12
… expected records, migrate base image (#32718)

Co-authored-by: pnilan <pnilan@users.noreply.github.com>
Copy link

vercel bot commented Nov 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2023 6:47pm

Copy link
Contributor

github-actions bot commented Nov 27, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Nov 27, 2023
@ChristoGrab ChristoGrab marked this pull request as ready for review November 28, 2023 16:38
Comment on lines 154 to 159
if start_date_parsed and state_date_parsed:
return max(start_date_parsed, state_date_parsed)
elif state_date_parsed or start_date_parsed:
return state_date_parsed or start_date_parsed
else:
return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if start_date_parsed and state_date_parsed:
return max(start_date_parsed, state_date_parsed)
elif state_date_parsed or start_date_parsed:
return state_date_parsed or start_date_parsed
else:
return None
# Return the maximum of the two dates if both are present, otherwise return whichever is present, or None
if start_date_parsed or state_date_parsed:
return max(filter(None, [start_date_parsed, state_date_parsed]), default=None)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -157,7 +181,11 @@ def stream_slices(self, stream_state: Mapping[str, Any] = None, **kwargs) -> Ite
stream_state = stream_state or {}
parent = Lists(authenticator=self.authenticator).read_records(sync_mode=SyncMode.full_refresh)
for slice in parent:
yield {"list_id": slice["id"]}
slice_ = {"list_id": slice["id"]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we can rename slice to parent_record and slice_ to slice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, updated

Comment on lines 504 to 505
if filter_date is None or record_cursor_value >= filter_date:
yield record
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is can be separate filtration function

check Hubspot connector as example

Copy link
Contributor Author

@ChristoGrab ChristoGrab Dec 20, 2023

Choose a reason for hiding this comment

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

Thanks for the pointer 👍 A separate method, filter_old_records, is now declared in the base MailchimpIncrementalStream class and invoked by streams which do not support the server-side filter.

@octavia-squidington-iv octavia-squidington-iv requested a review from a team December 20, 2023 10:59
Copy link
Collaborator

@lazebnyi lazebnyi left a comment

Choose a reason for hiding this comment

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

Nice!

@ChristoGrab ChristoGrab merged commit 8d33e38 into master Dec 20, 2023
26 checks passed
@ChristoGrab ChristoGrab deleted the christo/mailchimp-start-date branch December 20, 2023 21:59
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants