Repository navigation
Description
Connector
MongoDB Connector
Feature area
Metadata ingestion
Describe the bug
In OpenMetadata 2.0.5, a MongoDB field stored as BSON string is incorrectly registered as INT when its values are numeric-looking strings.
Source: MongoDB view DR_Ccccccc_V01
Field: CODIGO
Example value:
"01051"
Leading zeros are significant because the field represents a municipality code.
Source verification
The BSON type was checked directly on the MongoDB view:
db.DR_Ccccccc_V01.aggregate([
{$group: {_id: {$type: "$CODIGO"}, n: {$sum: 1}}}
])
Result:
{ _id: "string", n: 8137 }
Therefore, all 8,137 records have CODIGO as BSON string.
OpenMetadata result
Sample Data correctly preserves:
"01051"
However, OpenMetadata metadata returns:
"name": "CODIGO",
"dataType": "INT",
"dataTypeDisplay": "int"
and the UI consequently displays:
CODIGO (int)
Expected behavior
The MongoDB BSON type should be preserved:
CODIGO → STRING
instead of being inferred from its numeric-looking content as:
CODIGO → INT
Environment
OpenMetadata: 2.0.5
Connector: MongoDB
Source entity: MongoDB View
This behavior seems potentially related to #32075.
Could you confirm whether this is the same issue and whether it has been fixed or is planned for a future release?
To Reproduce
1. Create a MongoDB collection containing a string field with numeric-looking values and leading zeros, for example:
{ "CODIGO": "01051" }
2. Create a MongoDB view over that collection preserving the CODIGO field as string.
3. Verify the BSON type in the MongoDB view:
db.<view_name>.aggregate([ {$group: {_id: {$type: "$CODIGO"}, n: {$sum: 1}}} ])
The result should report _id: "string".
4. Ingest the MongoDB view into OpenMetadata using the MongoDB connector.
5. Open the ingested entity and check the CODIGO column type.
6. Open Sample Data and compare the value with the column metadata.
Actual result:
· MongoDB BSON type: string
· Sample Data preserves "01051".
· Column metadata reports dataType: "INT" and dataTypeDisplay: "int".
Expected result:
· CODIGO should be registered as a string type, matching the BSON type in MongoDB.
Expected behavior
A MongoDB field with BSON type string should be ingested as a string type in OpenMetadata, even when its values are numeric-looking strings such as "01051".
The source BSON type should not be re-inferred as INT based on the field content.
Connection / ingestion config
Logs
OS
Windows 11
Python version
OpenMetadata version
2.0.5
OpenMetadata Ingestion package version
Additional context
No response
Pre-submission checklist
- I searched for duplicate issues.
- I removed credentials, hostnames, emails, and other sensitive data from logs and config.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity
fix(nosql): preserve BSON string types during metadata ingestion (ope…
Fixes open-metadata#38303: preserve BSON string column types in Mongo…