diff --git a/dbms/include/DB/Dictionaries/MongoDBDictionarySource.h b/dbms/include/DB/Dictionaries/MongoDBDictionarySource.h index aa2d3e96bf2..48bf5fd6a30 100644 --- a/dbms/include/DB/Dictionaries/MongoDBDictionarySource.h +++ b/dbms/include/DB/Dictionaries/MongoDBDictionarySource.h @@ -97,9 +97,12 @@ public: BlockInputStreamPtr loadIds(const std::vector & ids) override { - /// @todo: convert ids to a BSONObj with $in and enumeration, pass as second argument to .query + /// mongo::BSONObj has shitty design and does not use fixed width integral types + const std::vector iids{std::begin(ids), std::end(ids)}; + const auto ids_enumeration = BSON(dict_struct.id.name << BSON("$in" << iids)); + return new MongoDBBlockInputStream{ - connection.query(db + '.' + collection, {}, 0, 0, &fields_to_query), + connection.query(db + '.' + collection, ids_enumeration, 0, 0, &fields_to_query), sample_block, 8192 }; }