Skip to content

Commit

Permalink
Document guess field type mapping in MongoDB
Browse files Browse the repository at this point in the history
Additionally, improve the sentence how to handle wrong table
definitions.
  • Loading branch information
ebyhr committed Feb 24, 2022
1 parent 9d8651e commit c031dcb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/src/main/sphinx/connector/mongodb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,27 @@ This property is required; there is no default. A connection url or seeds must b

As MongoDB is a document database, there is no fixed schema information in the system. So a special collection in each MongoDB database should define the schema of all tables. Please refer the :ref:`table-definition-label` section for the details.

At startup, this connector tries guessing fields' types, but it might not be correct for your collection. In that case, you need to modify it manually. ``CREATE TABLE`` and ``CREATE TABLE AS SELECT`` will create an entry for you.
At startup, the connector tries to guess the data type of fields based on the mapping in the following table.

================== ================ ================================================
MongoDB Trino Notes
================== ================ ================================================
``Boolean`` ``BOOLEAN``
``Int32`` ``BIGINT``
``Int64`` ``BIGINT``
``Double`` ``DOUBLE``
``Date`` ``TIMESTAMP(3)``
``String`` ``VARCHAR``
``Binary`` ``VARBINARY``
``ObjectId`` ``ObjectId``
``Object`` ``ROW``
``Array`` ``ARRAY`` Map to ``ROW`` if the element type is not unique
``DBRef`` ``ROW``
================== ================ ================================================

The initial guess can be incorrect for your specific collection. In that case, you need to modify it manually. Please refer the :ref:`table-definition-label` section for the details.

Creating new tables using ``CREATE TABLE`` and ``CREATE TABLE AS SELECT`` automatically create an entry for you.

This property is optional; the default is ``_schema``.

Expand Down

0 comments on commit c031dcb

Please sign in to comment.