MongoDB to BigQuery
Sync your MongoDB collections into BigQuery as tables you can query in SQL. Weld either unpacks the top level of each document into typed columns or lands the whole document as JSON, and keeps collections current with incremental syncs on a cursor field.
Checked against Weld and vendor docs on
Your own tables, picked when you set up the sync.
- Extract
- Load
- Keep in sync
- mongodb.Synced
- mongodb.Syncing
- mongodb.Synced
- mongodb.Synced
Trusted by data and AI teams
Three ways to get MongoDB data into BigQuery
Google offers two routes of its own: Datastream for change streams and a Dataflow template for batch copies. Both run in your Google Cloud project. The deciding questions are how documents should look in BigQuery, how fresh they need to be and who runs the pipeline.
Datastream
- Best for
- Change stream replication into BigQuery
- Effort
- Medium: source configuration, a connection profile and a stream
- Freshness
- Continuous after an initial copy of historical data
- Good to know
- Uses MongoDB change streams on replica sets and sharded clusters, for MongoDB versions later than 5.0, and replicates inserts, updates and deletes. Priced per GiB processed.
Dataflow MongoDB to BigQuery template
- Best for
- Batch copies you run and pay for in Dataflow
- Effort
- Medium: run a Dataflow job with network access to MongoDB
- Freshness
- Each run is a batch; a separate CDC template reads change streams
- Good to know
- In Beta. Stores each document as a JSON string, as BigQuery JSON, or flattened to top-level columns. The target dataset must already exist.
Weld
- Best for
- MongoDB alongside your other sources in one pipeline
- Effort
- Low: connection string, pick collections, choose a pack mode
- Freshness
- Incremental syncs on your schedule
- Good to know
- Unpacked mode gives typed top-level columns with nested objects as JSON; packed mode keeps each document whole. Incremental syncs use _id by default, or a modification timestamp you choose.
How to sync MongoDB to Google BigQuery with Weld.
In the app, with the API or an agent.
What lands in Google BigQuery
From MongoDB to Google BigQuery.
Each collection you select becomes a BigQuery table. What its columns look like depends on the pack mode you choose per collection.
- Collections in unpacked mode
Weld unpacks one layer of fields and infers their types, so top-level fields become columns and nested objects land as JSON in a single column.
- Collections in packed mode
Two columns: id, and json holding the whole document. Useful when documents vary a lot between records.
- _weld_synced
A timestamp Weld adds to every row with the time it was last synced. Use it to check freshness without touching your own fields.
Count documents by a field inside packed JSON.
In Google BigQuery SQL.
Runs in BigQuery against a dataset named mongodb, for a collection synced in packed mode. Illustrative: replace orders with your collection and status with one of its top-level fields. JSON_VALUE accepts both JSON strings and BigQuery's JSON type.
1select2 json_value(o.`json`, '$.status') as status,3 count(*) as documents,4 max(o._weld_synced) as last_synced_at5from mongodb.orders as o6group by status7order by documents descAsk your agent.
It queries Google BigQuery for you.
Connect Claude, Cursor, ChatGPT or your own agent to Weld over MCP. It reads the MongoDB context, finds the tables it needs and runs the query in Google BigQuery.
Which MongoDB tables do we have in Google BigQuery, and which is the largest?
Looking up what Weld has synced from MongoDB.
Things to know.
Before you sync MongoDB.
- The default cursor only sees new documents
- Incremental syncs use _id as the cursor by default, and _id is based on creation time, so updates to existing documents are missed. Switch the cursor to a field that records modification time, and index it so incremental queries stay fast.
- Keep _id as the primary key
- Weld strongly recommends keeping _id as the primary key, including when you switch the cursor to a modification timestamp.
- Only one level is unpacked
- Unpacked mode turns top-level fields into columns. Anything nested deeper arrives as JSON in its parent column, so plan to extract nested values with JSON functions in BigQuery.
- Changing pack mode resyncs the table
- Switching a collection between packed and unpacked mode triggers a full re-sync of that table. Choose the mode before the first large load where you can.
- CDC for MongoDB is not live yet
- Weld's MongoDB CDC, based on change streams, is listed as coming soon. Until then, syncs are incremental on a cursor field rather than streamed.
Sources: Weld MongoDB connector docs · Weld MongoDB Sharded Cluster docs · Weld MongoDB CDC docs · Weld BigQuery setup guide · Weld managed fields · Google Cloud: Datastream MongoDB source · Google Cloud: Datastream pricing · Google Cloud: MongoDB to BigQuery Dataflow template · Google Cloud: BigQuery JSON functions
Keep reading.
Guides, docs and schema.
Common questions.
About MongoDB to Google BigQuery.
Start syncing MongoDB to Google BigQuery.
Set up your MongoDB data pipeline in minutes. No credit card required. Free for 14 days.