Skip to Content
CatalogsMongoDB

MongoDB

catalog.database.collection

A MongoDB catalog is one deployment. Each Mongo database becomes a schema and each collection a table, so shop.orders in Mongo is mongo.shop.orders in SQL. There is no third part to learn: the collection is the table.

What you need

FieldNotes
HostThe deployment’s hostname, without mongodb:// and without a port
PortDefaults to 27017; ignored in SRV mode
DatabaseOptional. Leave it empty to expose every database the user can read; name one to limit the catalog to it. A user restricted to a single database should name it — listing every database needs the listDatabases privilege
User, passwordOptional if the deployment allows unauthenticated access. A read-only role is enough unless you intend to write
Authentication databaseWhere the user is defined — usually admin. Atlas users live in admin too
Atlas SRVSwitch on for mongodb+srv://, which is how Atlas connects. The SRV records carry the port
TLSOn by default; Atlas requires it. Turn it off only for a local deployment that has none
Read-onlyOptional. Blocks writes at attach time, whatever the SQL says

The password is percent-encoded by Thunderduck before it reaches the connection URI, so spaces, @, : and / are fine — do not encode it yourself.

Finding the connection details

In MongoDB Atlas: Database → Connect → Drivers shows the host to use and whether the cluster wants the mongodb+srv:// form. Atlas requires TLS and requires the user to be defined in admin.

For a self-hosted deployment, use the hostname or IP and the port the server listens on. The server must be reachable from Thunderduck’s network.

Atlas Network Access

Atlas only accepts connections from addresses in the project’s Network Access list, and for every other address it refuses the TLS handshake — so a missing entry does not look like a timeout. The connection fails with SSL handshake failed … tlsv1 alert internal error (pymongo / DuckDB) or SSL alert number 80 (libmongoc), which names Atlas’s own shard host and says nothing about the allowlist.

Add 18.213.15.249 under Network Access → Add IP Address (0.0.0.0/0 only as a temporary test; the full list, and what else it is used for, is in static egress addresses), then refresh the catalog. Until that entry exists, the catalog attaches but lists no collections and every query fails.

Collections are schemaless

MongoDB documents do not declare columns, so DuckDB samples the documents in each collection and infers them. That has consequences worth knowing:

  • A field that appears in only some documents can be missing from the inferred column list; a field that holds different types can come back as a widened type.
  • Nested objects are flattened into parent_child columns, and the parent object is also available as JSON — so customer.name is the column customer_name, or customer->>'$.name' on the JSON value.
  • Arrays come back as DuckDB lists.

Metadata collection lists collections and their inferred columns. It never scans a collection’s documents beyond that sample, so it stays cheap on large collections.

Writing

The catalog is writable by default; INSERT, CREATE TABLE … AS SELECT and COPY … TO work if the Mongo user’s role permits them and the catalog is not marked read-only.

CREATE TABLE … AS SELECT creates the collection, so it fails if the collection already exists. To reuse a name, drop it first:

DROP TABLE IF EXISTS mongo.shop.orders; CREATE TABLE mongo.shop.orders AS SELECT * FROM lake.orders;

CREATE OR REPLACE TABLE does not fail on an existing collection, but it appends to it rather than replacing its documents. Use DROP TABLE when you want exactly the new rows.