Skip to content

Commit

Permalink
MongoDB Full: Use limit parameter as number of total records
Browse files Browse the repository at this point in the history
... when given.
  • Loading branch information
amotl committed Sep 22, 2024
1 parent 9ed5a17 commit a5edb62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- MongoDB Full: Improved initialization of transformation subsystem
- MongoDB Adapter: Improved performance of when computing collection cardinality
by using `collection.estimated_document_count()`
- MongoDB Full: Optionally use `limit` parameter as number of total records

## 2024/09/19 v0.0.24
- MongoDB Full: Refactor transformation subsystem to `commons-codec`
Expand Down
6 changes: 5 additions & 1 deletion cratedb_toolkit/io/mongodb/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def start(self):
Read items from MongoDB table, convert to SQL INSERT statements, and submit to CrateDB.
"""
logger.info(f"Starting MongoDBFullLoad. source={self.mongodb_uri}, target={self.cratedb_uri}")
records_in = self.mongodb_adapter.record_count()
limit = self.mongodb_adapter.limit
if limit > 0:
records_in = limit
else:
records_in = self.mongodb_adapter.record_count()
logger.info(f"Source: MongoDB {self.mongodb_adapter.address} count={records_in}")
with self.cratedb_adapter.engine.connect() as connection, logging_redirect_tqdm():
if not self.cratedb_adapter.table_exists(self.cratedb_table):
Expand Down
1 change: 1 addition & 0 deletions doc/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
mongoimport --uri 'mongodb+srv://MYUSERNAME:SECRETPASSWORD@mycluster-ABCDE.azure.mongodb.net/test?retryWrites=true&w=majority'
```
- MongoDB: Convert dates like `"date": "Sep 18 2015"`, see `testdrive.city_inspections`.
- Table Loader: Propagate offset/limit to progress bar

## Iteration +2
- Address `fix_job_info_table_name`
Expand Down

0 comments on commit a5edb62

Please sign in to comment.