Replies: 2 comments 1 reply
|
This is very useful since nearly 30% of data sources for our data platform are mongodb. |
0 replies
|
@satya323, This would be great as a third party library, but don't think it's right to add this into daft repo. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Feature Summary
Add a Rust based
daft.read_mongodb()connector that reads MongoDB collections into Daft DataFrames with explicit schema, server-side filter and projection pushdown, and optional distributed range reads. The connector is designed for operational MongoDB workloads: it does not sample or infer schema during planning, and it exposes knobs such ashint,max_time_ms, and user-providedpartition_rangesto keep reads bounded and index-friendly. BSON values are converted into the user-provided Daft schema at execution time, with support for nested structs and lists.Example Usage
Corner-case Behavior
Schema and BSON conversion
struct,list).Filters and predicate pushdown
filter+ Daftwhere: Supported MongoDB predicates are merged into a single server-side filter document.==,!=,<,<=,>,>=),between,is_inwith literals,is_null,not_null, and conjunctions of supported predicates.not, or unsupported operators are not pushed to MongoDB.daft.context.set_planning_config(enable_strict_filter_pushdown=True)is enabled, unsupported predicates remain above the scan. Without strict mode, planning fails if a pushed filter cannot be fully represented in MongoDB.!=semantics: Pushed as a null-safe MongoDB filter using$exists,$ne: null, and$ne: <value>.$oid,$numberLong,$numberInt,$numberDouble,$date, and canonical$binaryare accepted; malformed or non-canonical extended JSON is rejected at planning time.Projection pushdown
selectpushdown: Selected columns are pushed into the MongoDB projection when possible._idbehavior: If_idis not in the Daft schema, MongoDB's default_idfield is excluded from the server projection unless the user projection explicitly includes it._id) is rejected at planning time.Distributed reads and partitioning
partition_rangesomitted: A single scan task is created. No hidden metadata query is issued to infer collection bounds.partition_rangesprovided:partition_fieldis required. One MongoDB scan task is created per half-open(lower, upper)range.Noneon the lower or upper bound means unbounded on that side.lower >= upper) are rejected at planning time.partition_fieldwith comparable values ($eq,$in,$gt,$gte,$lt,$lte, and supported$and/$orshapes), scan tasks for non-overlapping ranges are skipped.partition_field(e.g.$inwith nested documents, mixed$orbranches), all partition ranges are retained to avoid dropping data.{"value": {"$gte": 20, "$lt": 10}}or{"value": {"$in": []}}) result in zero scan tasks.Limits, batching, and operational safety
limitpushdown: Applied to MongoDB only when a single scan task remains after partitioning/pruning. For multiple scan tasks, per-task limits are not pushed and Daft applies the limit after the scan.max_time_ms: Bounds each server-sidefindoperation.hint: Accepts either an index key document or an index name string.batch_size: Controls MongoDB cursor batch size and acts as a Daft task batch hint.Out of scope for initial proposal
partition_rangesfor distributed reads.All reactions