[SERVER-62500] Improve "ks" VM function to support all BSON types Created: 11/Jan/22 Updated: 06/Dec/22 Resolved: 16/Mar/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Critical - P2 |
| Reporter: | Drew Paroski | Assignee: | Backlog - Query Execution |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||||||
| Sprint: | QE 2022-01-24 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
1) Check out the master branch at or after git rev 50db8e9573e1 (" 2) Build. 3) Launch mongod with the new optimizer enabled: 4) Launch mongo shell and run the following commands:
You should get the following error message:
This error is happening because the "ks" VM builtin function does not support all types yet. The implementation of the "ks" VM builtin function is provided by the ByteCode::builtinNewKeyString() method in "src/mongo/db/exec/sbe/vm/vm.cpp". The goals of this task are: (1) to improve the implementation of the "ks" VM builtin function so that it supports all types; (2) to write unittests for the "ks" VM builtin function passing in every possible BSON type; and (3) to add some jstest coverage for queries that pass different types to the "ks" VM builtin function. For goal #3, I'd recommend taking a look at some the existing jstests in the "jstests/aggregation/abt" folder, in particular:
Note that the "ks" VM builtin function does not need to support SBE types that do not have a corresponding BSON type. This is means that the "ks" VM function does not need to support TypeTags::LocalLambda, TypeTags::ksValue, TypeTags::pcreRegex, TypeTags::timeZoneDB, TypeTags::jsFunction, TypeTags::shardFilterer, TypeTags::collator, TypeTags::ftsMatcher, or TypeTags::sortSpec (if any of these types are passed in, the "ks" VM function should either return Nothing or it should throw an error). Likewise, when two or more SBE types represent the same BSON type, such as TypeTags::Object and TypeTags::bsonObject, such types should be encoded in the same way (i.e. given an Object and and a bsonObject that contain the same values, their encodings should be indistinguishable from each other). |
| Comments |
| Comment by Nikita Lapkov (Inactive) [ 16/Mar/22 ] |
|
We will extend "ks" to support all types in |