Skip to content

Commit

Permalink
fix(ingestion/mongodb): MongoDB source unable to parse datetimes with…
Browse files Browse the repository at this point in the history
… years > 9999 (#10110)

Co-authored-by: JonasHan <zengqh12>
  • Loading branch information
jonasHanhan authored Apr 4, 2024
1 parent 7eb59b4 commit 294b6d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metadata-ingestion/src/datahub/ingestion/source/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Dict, Iterable, List, Optional, Tuple, Type, Union, ValuesView

import bson.timestamp
import pymongo
import pymongo.collection
from packaging import version
from pydantic import PositiveInt, validator
Expand Down Expand Up @@ -282,7 +281,8 @@ def __init__(self, ctx: PipelineContext, config: MongoDBConfig):
**self.config.options,
}

self.mongo_client = pymongo.MongoClient(self.config.connect_uri, **options) # type: ignore
# See https://pymongo.readthedocs.io/en/stable/examples/datetimes.html#handling-out-of-range-datetimes
self.mongo_client = MongoClient(self.config.connect_uri, datetime_conversion="DATETIME_AUTO", **options) # type: ignore

# This cheaply tests the connection. For details, see
# https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient
Expand Down

0 comments on commit 294b6d4

Please sign in to comment.