Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-59757

Evaluate supporting queries with match expressions on empty field names in SBE

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • QE 2022-09-19

      There are queries in mongo that are valid which match on an empty field name (""). That means that documents such as these will be returned

      {"": 1} 

      Initially it was brought to our attention that SBE does not support this, and we found the reason was that we have to treat empty strings in a special way when generating nested traversals in SBE. The way recursive path traversal is implemented in SBE, if we wanted to start supporting a query like this, we would have to remove the special meaning an empty string has in $elemMatch (https://github.com/mongodb/mongo/blob/8179692b362d8237f201719946eb46bac6a5e961/src/mongo/db/matcher/expression_parser.cpp#L1276), because otherwise the SBE traversal code cannot tell if an empty string is coming from this parser code or if the empty string is actually something that we are trying to match against. The correct solution would be to refactor the code that makes an empty string have a special meaning and instead perhaps use boost::optional, but that is a massive change that is very invasive since every match expression expects a StringData and not an optional.

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            andrii.dobroshynski@mongodb.com Andrii Dobroshynski (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: