ogiogidayo opened a new pull request, #39901:
URL: https://github.com/apache/beam/pull/39901

   Fixes #39900.
   
   `BoundedMongoDbSource.splitKeysToFilters` formatted split boundaries 
unconditionally as `ObjectId("...")`, so collections keyed by non-ObjectId 
`_id` values (e.g. application-defined string ids, which MongoDB fully 
supports) failed with `IllegalArgumentException: state should be: hexString has 
24 characters` as soon as read splitting was enabled via `withBucketAuto(true)` 
or `withNumSplits(n)`. The AggregationQuery path (`splitKeysToMatch`) had the 
same assumption via `getObjectId("_id")`.
   
   This change serializes split boundaries with their actual BSON types:
   
   - `splitKeysToFilters` now builds the range filters as `Document`s and 
serializes them with `Document#toJson` (extended JSON). ObjectId boundaries 
keep producing semantically identical filters, while string/integer ids are 
preserved.
   - `splitKeysToMatch` keeps the raw `_id` value instead of reading it as an 
ObjectId. The generated `$match` documents for ObjectId ids are unchanged (the 
pre-existing expectations in `testSplitIntoBucket` pass without modification).
   
   Backward compatible: no public API change. Note that `testSplitIntoFilters` 
previously asserted output that could never be parsed back (`ObjectId("56")` 
for an Integer id, which only passed because the test compared strings without 
parsing them); it now verifies the generated filters by parsing them. Added 
string-id tests for both paths.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [x] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable. This will automatically add a link to the 
pull request in the issue. If you would like the issue to automatically close 
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [x] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to