MS-Kinguin opened a new issue, #30471:
URL: https://github.com/apache/beam/issues/30471

   ### What happened?
   
   ### Cause of the problem
   
   My collection in MongoDB on Atlas has an incorrect date value in one of the 
fields:
   
   `
   registrationDate:
   0000-12-30T00:00:00.000+00:00`
   
   The issue arises because the pipeline cannot progress to the transform stage 
where I could fix it. It fails while reading the data with the connector, 
displaying the following error:
   
   `bson.errors.InvalidBSON: year 0 is out of range (Consider Using 
CodecOptions(datetime_conversion=DATETIME_AUTO) or 
MongoClient(datetime_conversion='DATETIME_AUTO')). See: 
https://pymongo.readthedocs.io/en/stable/examples/datetimes.html#handling-out-of-range-datetimes`
   
   This failure likely occurs at some validation level of the BSON object when 
attempting to connect to Atlas. To my knowledge, utilizing CodecOptions is not 
feasible at the mongodbio connector level. Here is my current setup:
   
   ` | "Read documents" >> 
beam.io.ReadFromMongoDB(uri='mongodb+srv://user:[email protected]/?retryWrites=true&w=majority&readPreference=secondary',
                                                        db="database",
                                                        coll="collection",
                                                        filter=query,
                                                        bucket_auto=True)`
   
   While the direct solution is to adjust the values in Atlas, it's well-known 
that data quality can be an issue, even in production environments, and often 
it's beyond our control. Simply filtering out these documents is a workaround, 
not a solution. It would be beneficial if the connector could automatically 
detect and correct the year 0 to a different placeholder date. I have observed 
such functionality in custom JDBC drivers for Mongo Atlas in different 
environments (Data Fusion + Dataproc).
   
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [X] Component: Python SDK
   - [ ] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
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