skip to main content
Welcome to the Progress DataDirect for JDBC for MongoDB Driver : Data Types : Default Mapping of Columns with Inconsistent Native Data Types
  

Try DataDirect Drivers Now

Default Mapping of Columns with Inconsistent Native Data Types

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 JDBC. If you need to change the JDBC data type, default mappings can be overridden using the Schema Tool. See "Defining Columns" for additional information.
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.
Table 4. Default Mapping for Columns Containing Inconsistent MongoDB Data Types
MongoDB Data Types
JDBC Data Type
Bigint and Integer
BIGINT (-5)
Double and Integer
DOUBLE (8)
All other combinations
VARCHAR (12) or LONGVARCHAR (-1)1

1 When the driver discovers a column with 4000 characters or less, the column is mapped as VARCHAR and the precision is 4000 characters. When the driver discovers a column with more than 4000 characters, the column is mapped as LONGVARCHAR and precision is 16 MB. You can map columns to any supported data type, regardless of the size, using the Schema Tool. See "Creating and Customizing Schemas Using the DataDirect Schema Tool" and "Defining Columns" for details.