Default mapping of columns with inconsistent native data types
- Last Updated: July 30, 2025
- 1 minute read
- DataDirect Connectors
- ODBC
- MongoDB 8.0
- Documentation
Due to the flexibility of the MongoDB schema data model, your native data sources may not enforce consistent data types. To ensure data integrity when mapping to a relational model, the driver describes columns with inconsistent native data types as a single SQL data type. The driver determines which SQL type to use based on the combination of native types detected when sampling data. The following table lists combinations of MongoDB data types and their default mapping for ODBC.
Note: In some cases, a value with a specific native type can be concealed or
obscured because the driver describes a field with inconsistent native types as a column with
a single SQL type. The CAST_TO_NATIVE function escape allows users to send a value as it is
defined in the MongoDB database, rather than how it is described in the relational model of
the data. Currently, CAST_TO_NATIVE can only be used with the ObjectID type in SELECT
statement filters and literal INSERT values. See "CAST_TO_NATIVE function escape" for
details.
| MongoDB Data Types | ODBC Data Type |
|---|---|
| Bigint and Integer | SQL_BIGINT |
| Double and Integer | SQL_DOUBLE |
| All other combinations | SQL_WVARCHAR or WLONGVARCHAR1 |
1 Whether columns are mapped as either WVARCHAR or WLONGVARCHAR
depends on the size of the data of the sampled rows.