ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We need to extend narrowPath, since it only covers the most basic cases right now.

      We should support NonLeafArrayBehaviors kTraverse and kNoTraverse. The kMatchSubpath and kTraverseOmitArray do not seem required for the match expressions that we want to type.

      The BSONElementIterator class and other logic in src/mongo/db/matcher/path.cpp holds the execution code that we are trying to type, so we should use that as a guide. That code shows exactly what kMatchSubpath does for example.

      Since leaf and non-leaf traversal are set independently, we will have to derive the type for both, depending on the enum.

      For NonLeafArrayBehavior:

       - kTraverse - each component can be object or array holding matching element

       - kNoTraversal - must be an object since arrays on the prefix are not produced

       - kMatchSubpath - not supported

      With dotted paths, there is a special case when traversing a primitive - it produces missing, which means that when the constraint type matches 'missing' we must leave primitives as valid on the prefix. For example {a.b: null} will match the document {a: 5}. The predicate there matches null|missing and since a.b for a=5 produces missing it matches, so we cannot eliminate the primitives.

      But we should be able to traverse the input using the path, and apply the constraints at every level.

      Examples:
       - {a.b: {$type: 'number'}} - {a: array(S)|

      {b: number|array(S), ...}

      , ...} that is a is array or object and the object has b either array or number

       - {a.b: {$not: {$type: 'array'}}} - 'a' is any value, but if object, the shape will have b: ~array.

       - {a.b.c: {$type: 'number'}} followed by a sequence of $not: {$type: array} on a, then a.b, then a.b.c should produce exactly {a: {b: {c: number}}}} (no arrays)

            Assignee:
            Henri Nikku
            Reporter:
            Vesko Karaganev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: