-
Notifications
You must be signed in to change notification settings - Fork 320
Streaming added full document before change support #140
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
Streaming added full document before change support #140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for MongoDB change stream pre-images via the change.stream.lookup.full.document.before.change configuration option, enabling access to the full document state before delete, update, or replace operations. This is essential for preserving deleted document data for downstream consumers when the MongoDB deployment has pre-image collection enabled.
- Added new configuration constant
STREAM_LOOKUP_FULL_DOCUMENT_BEFORE_CHANGE_CONFIGwith comprehensive documentation - Implemented
getStreamFullDocumentBeforeChange()method to retrieve and validate the configuration value - Integrated
fullDocumentBeforeChange()calls in both streaming partition readers
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/com/mongodb/spark/sql/connector/config/ReadConfig.java | Adds configuration constant, default value, documentation, and getter method for full document before change support |
| src/main/java/com/mongodb/spark/sql/connector/read/MongoMicroBatchPartitionReader.java | Configures change stream iterable to use the full document before change setting |
| src/main/java/com/mongodb/spark/sql/connector/read/MongoContinuousPartitionReader.java | Configures change stream iterable to use the full document before change setting |
| src/test/java/com/mongodb/spark/sql/connector/config/MongoConfigTest.java | Adds comprehensive unit test covering all valid options (default, off, whenAvailable, required) and invalid input handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/mongodb/spark/sql/connector/config/ReadConfig.java
Outdated
Show resolved
Hide resolved
Fix javadoc issues
SPARK-449 Original PR: mongodb#140 --------- Co-authored-by: Ross Lawley <[email protected]>
|
Closed in favor of: #144 - which takes this PR as a base |
SPARK-449 Original PR: mongodb#140 --------- Co-authored-by: Ross Lawley <[email protected]>
Motivation
We’re adding
change.stream.lookup.full.document.before.changeto ensure that we can access the full document prior to a delete operation in MongoDB change streams.This is particularly important for our use case where:
We’re setting this as a configurable option to remain compatible with MongoDB deployments.