Denodo MongoDB Custom Wrapper - User Manual 20231130
Denodo MongoDB Custom Wrapper - User Manual 20231130
Revision 20231130
NOTE
This document is confidential and proprietary of Denodo Technologies.
No part of this document may be reproduced in any form by any means without prior
written authorization of Denodo Technologies.
Copyright © 2025
Denodo Technologies Proprietary and Confidential
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
2 of 34
CONTENTS
1 INTRODUCTION.................................................................5
2 WHAT IS MONGODB?.........................................................6
3 REQUIREMENTS................................................................7
5 USAGE............................................................................ 11
5.3.1 BASICS.....................................................................15
5.3.2 EXAMPLE..................................................................16
5.3.3 SCHEMAS..................................................................18
5.3.3.1.1.1 JSON................................................................20
5.3.3.1.1.2 OBJECTID..........................................................22
5.3.4 TLS/SSL....................................................................24
5.3.5 AUTHSOURCE............................................................25
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
3 of 34
5.5 INSERT........................................................................26
5.6 UPDATE.......................................................................26
5.7 DELETE........................................................................ 26
8 LIMITATIONS...................................................................35
8.1 WRITE OPERATIONS.....................................................................35
8.2 MONGODB BSON TIMESTAMP DATA TYPE......................................35
8.3 LIMITATIONS IN SELECT SENTENCES.............................................35
8.4 USER PRIVILEGES ON OLDER VERSIONS OF MONGODB (BELOW 4.0)35
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
4 of 34
1 INTRODUCTION
It bridges (to some extent) the gap between NoSQL and relational databases by
establishing a predefined schema for output, thus enabling SQL queries on MongoDB.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
5 of 34
2 WHAT IS MONGODB?
MongoDB is one of the most prominent so-called NoSQL databases, although it would
be more accurate to say that is a non-relational database, or as defined on their
website: "A document-oriented, scalable and high performance database", developed
by 10gen.
In MongoDB we can forget about the table: we have collections which are groups of
documents that do not have to share any common schema. So documents are to
MongoDB something very similar to what tuples represent to relational databases, only
without the schema restrictions associated with the latter.
Another important feature is the way in which MongoDB stores documents: BSON
(Binary JSON). The binary part is hidden from us when we work with MongoDB, and thus
we see and treat these data in JSON format, so our documents are in fact JSON objects,
and its fields are the equivalent to the columns of the relational world. But as we do
not need the documents in a collection to share a common schema, each JSON
document can have just the fields it needs, and all documents in a collection do not
have to represent entities of the same nature.
And you can also forget about both the SQL language and the JDBC API. MongoDB does
not use SQL but its own query API, and consequently offers a specialized driver for Java
that acts as a client and interacts with the database.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
6 of 34
3 REQUIREMENTS
● When used with Denodo 5.5: At least the Denodo update 20170529
● When used with Denodo 6.0: At least the Denodo update 20170515
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
7 of 34
After making the connection, the custom wrapper can create base views to read
collections and documents as if they were tables and rows. Each base view will be
created on a specific collection.
Once the base views are created, VDP will be able to perform queries on MongoDB
using the VQL Shell, create derived views, etc.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
8 of 34
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
9 of 34
○ Since common fields may hold different types of data the resulting
structure is the highest common denominator between all the fields with
the same name. In case of incompatible fields --such as integer and
subdocuments-- VDP interprets them as of type text. But notice that
MongoDB is strict about types and you must query for data using the
correct type, so this fields would not be searchable.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
10 of 34
5 USAGE
In order to use the MongoDB Custom Wrapper in VDP, we must configure the Admin
Tool to import the extension.
No other jars are required as this one will already contain all the required
dependencies, including the MongoDB Java driver classes.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
11 of 34
Go to New → Data Source → Custom and specify the wrapper’s class name
com.denodo.connect.mongodb.wrapper.MongoDBWrapper. Also check ‘Select Jars’
and select the jar file of the custom wrapper.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
12 of 34
Base views created from the MongoDBWrapper need to fill in the Database parameter or
the Connection string parameter, both of them are mutually exclusive.
[mongodb://]host1[:port1][,host2[:port2],...
[,hostN[:portN]]]/database[?options]
The prefix mongodb:// is optional, the database is mandatory and user and
password are not written in this field, but in the User and Password
parameters.
You can see all the options in the documentation of mongodb, in the following
link about Connection String URI Format.
If you introduce this parameter, Host, Port and Database parameters should be
empty.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
13 of 34
● Port: Port number to connect to MongoDB, default is 27017. Only with Database
parameter.
● Use SSL/TLS: Enabling this checkbox will make the wrapper use SSL/TLS. When
using a Connection String, this can also be specified by means of the
“ssl=true” option.
● Kerberos KeyTab File: Location of the keytab file to be used, which should
contain valid authentication credentials for the principal specified above. When
using Kerberos authentication, it is required to set a value to either this
parameter or to Kerberos JAAS Configuration.
com.sun.security.jgss.krb5.initiate {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
14 of 34
debug=true
refreshKrb5Config=true
useTicketCache=true
ticketCache="file:///home/someuser/krb5cc_someuser"
principal="someuser@REALM";
};
5.3.1 Basics
Once the custom wrapper has been registered, click on Create a base view.
Collection is mandatory
● Fields: The fields we would like to import as columns in VDP. We must keep the
syntax
field1:type1[,field2:type2,...].
Type should be one of the constants in java.sql.Types (note these are SQL
standard types). See a specific section below to learn more about the allowed
syntax.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
15 of 34
to check the types of the new view inferred from the introspection.
This query requires MongoDB syntax.
5.3.2 Example
At the beginning of the document, the schema must contain general product
information, to facilitate searches of the entire catalog. Then, a details subdocument
that contains fields that vary between product types.
As we are only interested in albums and films products we use the following
introspection query:
MongoDB Base View edition using Host, Port and Database parameters
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
16 of 34
The resulting schema for this product catalog collection can be seen in the image
below. It contains common product information like title, type, pricing and the
details subdocument.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
17 of 34
5.3.3 Schemas
The use of the Fields parameter for specifying the view’s schema explicitly is
recommended for base view creation when there are complex fields involved coming
from mongoDB and there is a possibility that these data are not always returned in the
same order or with the same type when using an introspection query.
We will need to specify the fields we would like to import as columns in VDP, using this
syntax:
field1:type1[,field2:type2,...].
Type should be one of the constants in java.sql.Types (note these are SQL standard
types).
● Default is VARCHAR.
● If documents in the same collection specify different types for fields with the
same name, using VARCHAR (text in VDP) for that column will automatically
perform the required conversions to show data from those documents.
● Note that the SQL equivalent to MongoDB’s “Date” type is SQL’s TIMESTAMP, as
MongoDB Date values contain both date and time.
● MongoBD’s internal “BSON Timestamp” data type is supported as SQL
TIMESTAMP too, but with some limitations (see section at the end).
● BinData type from BSON is supported and it will be defined as BLOB in VDP.
● Nested arrays syntax is array(array(\{"field":VARCHAR\})).
See an example of explicit schema specification (note braces for complex objects
should be escaped):
_id : VARCHAR,
firstName : VARCHAR,
lastName : VARCHAR,
age : VARCHAR,
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
18 of 34
address: \{
city : VARCHAR,
state : VARCHAR,
streetAddress : VARCHAR,
state : VARCHAR,
postalCode : VARCHAR
\},
phoneNumbers: array(\{
aaa : VARCHAR,
type : VARCHAR,
number : VARCHAR
\}),
cc:array(VARCHAR)
See how complex structures are specified using braces ({...}) and arrays using the
array keyword and specifying the contents of the array between parentheses.
Also field names can be surrounded by single or double quotes (e.g. "phone number")
if they contain white spaces or non-alphanumeric chars.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
19 of 34
Fields Parameter
5.3.3.1.1.1 JSON
Although the allowed data types are defined in java.sql.Types, there is the possibility
to be able to obtain a raw JSON (text) for a field at a given level, rather than
introspecting and obtaining an array/register. To do this, you just only need to specify
the desired field as JSON. For example, for an example collection such as:
We could create a base view obtaining the JSON representation for the awards field:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
20 of 34
So the result of executing a sample query against this view would be:
If we extract the value of the awards field we can see that it’s a JSON formatted text
block:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
21 of 34
NOTE: Although a field is defined in the base view creation as JSON, VDP will display it
as text type.
5.3.3.1.1.2 ObjectID
This BSON type isn’t defined under java.sql.Types either, but ObjectID fields can be
defined manually for a base view. For example:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
22 of 34
If you don’t want to explicitly define the schema, you should use the Introspection
query parameter. For this you should use a query over the collection, following the
syntax for the mongodb method db.collection.find(). You should escape the
braces.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
23 of 34
5.3.4 TLS/SSL
The MongoDB API for Java Driver allows the connection to a MongoDB Server that has
TLS/SSL enabled. To create a Base view using SSL, you have to add the option
ssl=true in the Connection String parameter. ssl is one of the Connection Options
of the Connection String URI. Alternatively (or additionally), you can also check the Use
SSL/TLS checkbox at view creation time.
In addition, if you are using a self-signed certificate, you have to import it into the
TrustStore of the JVM of the Denodo Platform. The section “Importing the Certificates of
Data Sources (SSL/TLS Connections)” of the Denodo Platform Installation Guide
explains how to do this.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
24 of 34
Also note that in order to use TLSv1.2 in Denodo 6 (with Java 7), you will need to add
the property “com.denodo.parser.connection.http.tlsProtocol=TLSv1.2” to the
VDBConfiguration.properties file.
5.3.5 AuthSource
In MongoDB it is possible to authenticate against a database but read the data from a
different one. When the authentication is done in a different database, you have to add
the option authsource in the Connection String parameter. authsource is one of the
Connection Options of the Connection String URI. If you use this option Host, Port and
Database parameters should be empty.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
25 of 34
5.5 INSERT
This wrapper allows to make insertion. No complex fields are allowed.
5.6 UPDATE
This wrapper allows you to make updates in a document. No complex fields are
allowed.
5.7 DELETE
It is allowed to delete documents of a collection.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
26 of 34
If your Cosmos DB account was created before mid-October 2019 and/or your MongoDB
API version at the Cosmos DB side is 3.2 or earlier, you need to enable the
Aggregation Pipeline functionality in the Azure portal, inside the "Preview Features"
section. Otherwise the Denodo MongoDB Custom Wrapper won’t work.
Now, you can use this wrapper to access Azure Cosmos DB, taking advantage of their
MongoDB protocol API. So let’s see the steps for creating an example base view over an
example collection called cosmosdb_collection in a database called databasename.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
27 of 34
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
28 of 34
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
29 of 34
2. Create the base view. Here we set the collection name (in our example,
cosmosdb_collection) as well as Fields or Introspection query the way it was
explained in the “Specifying Fields” and “Introspection Queries” sections:
Once you click in the Accept button, you’ll finally see the base view:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
30 of 34
NOTE: If you are using Java 7 (Denodo 6), please note you need to enable TLS 1.2 as
Cosmos DB requires at least this version.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
31 of 34
You can use this wrapper to access Alibaba Cloud ApsaraDB for MongoDB. So let’s see
the steps for creating an example base view over an example collection called
apsaradb_collection in a database called admin.
You must click on Apply for Public Connection String and use this
connection string, with the format mongodb://
[username:password@]host1[:port1][,host2[:port2],...
[,hostN[:portN]]][/[database][?options]]
in the Denodo MongoDB Custom Wrapper configuration:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
32 of 34
● Create the base view. Here we set the collection name (in our example,
apsaradb_collection) as well as Fields or Introspection query the way it was
explained in the “Specifying Fields” and “Introspection Queries” sections:
Once you click in the Accept button, you’ll finally see the base view:
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
33 of 34
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com
Denodo MongoDB Custom Wrapper 20231130
34 of 34
8 LIMITATIONS
If you try this operation, you can see the following exception, in the output of the VQL
shell:
Note however that “BSON Timestamp” data types are not supported in WHERE clauses
in updates/deletes, nor they will be used in INSERT or UPDATE sentences to set new
values into MongoDB (new values will be set as BSON Date, not BSON Timestamp). You
can use them in select queries, but notice that filtering will be done in memory instead
of directly in the data source.
Also note that functions are not delegated to the mongoDB server, and therefore any
WHERE clauses containing functions will be executed by Virtual DataPort after retrieving
the target data, and not at the mongoDB server.
Denodo Inc.: 525 University Avenue, Suite 31, Palo Alto, CA 94301. USA www.denodo.com