TDV Adapter for MongoDB

Build 21.0.8137

Automatic Schema Discovery

The adapter automatically infers a relational schema by inspecting a series of MongoDB documents in a collection. You can use the RowScanDepth property to define the number of documents the adapter will scan to do so. The columns identified during the discovery process depend on the FlattenArrays and FlattenObjects properties.

Flattening Objects

If FlattenObjects is set, all nested objects will be flattened into a series of columns. For example, consider the following document:

  id: 12,
  name: "Lohia Manufacturers Inc.",
  address: {street: "Main Street", city: "Chapel Hill", state: "NC"},
  offices: ["Chapel Hill", "London", "New York"],
  annual_revenue: 35,600,000
This document will be represented by the following columns:

Column NameData TypeExample Value
nameStringLohia Manufacturers Inc.
address.streetStringMain Street
address.cityStringChapel Hill
officesString["Chapel Hill", "London", "New York"]

If FlattenObjects is not set, then the address.street,, and address.state columns will not be broken apart. The address column of type string will instead represent the entire object. Its value would be {street: "Main Street", city: "Chapel Hill", state: "NC"}. See JSON Functions for more details on working with JSON aggregates.

Flattening Arrays

The FlattenArrays property can be used to flatten array values into columns of their own. This is only recommended for arrays that are expected to be short, for example the coordinates below:

"coord": [ -73.856077, 40.848447 ]
The FlattenArrays property can be set to 2 to represent the array above as follows:

Column NameData TypeExample Value

It is best to leave other unbounded arrays as they are and piece out the data for them as needed using JSON Functions.

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 21.0.8137