Skip to content

Fix MongoDB connector by adding codec options #34365

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

Closed
wants to merge 3 commits into from

Conversation

haperski
Copy link

Fix MongoDB connector to handle out-of-range dates


Changes Made:

  • Modified the mongodbio.py file to include CodecOptions and DatetimeConversion.
  • Specifically, added CodecOptions(datetime_conversion=DatetimeConversion.DATETIME_CLAMP) to ensure that out-of-range dates are converted properly when reading data from MongoDB.
  • Updated the _get_head_document_id and read methods to use the new codec options when connecting to the MongoDB database.

Results After Changes

With the introduced changes, all instances of out-of-range dates can now be read and later transformed.

(https://pymongo.readthedocs.io/en/stable/examples/datetimes.html#handling-out-of-range-datetimes)

Discussion

This issue has been discussed on the Apache Beam mailing list, with recommendation from XQ Hu to address this issue with PR.

See the Contributor Guide for more tips on how to make the review process smoother.

To check the build health, please visit Build Status.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

Copy link
Contributor

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label May 20, 2025
Copy link
Contributor

This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions bot closed this May 27, 2025
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.

[Bug]: year 0 is out of range when connecting to MongoDB Atlas (SDK 2.53.0)
1 participant