• 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

      The signature should be something like:

      enum class PathSemantics { kFieldPath, kOther };
      Type expression::traversePath(Type, FieldPath, PathSemantics);

      traversePath should implement the traversal semantics used in the evaluation of the Expression classes and return the Type of the result.

      There's a few different ways in which a path can be traversed in a pipeline:

      •  FieldPathExpression - the $a.b syntax
      •  GetFieldExpression - the $getField expression
      •  Document::getNestedField - method called in aggregation pipelines in places, not strictly within Expressions.
      •  there might be more!

      We are only implementing the $a.b case in this project, the rest falls implicitly under kOther and will not be implemented.

      See the Design Appendix.

      It shows some of the values that are produced from $a.b. The evaluation code is in evaluatePath and evaluateArrayPath in evaluate_bson.cpp and that is what we need to replicate in the Type system.

      Our expression::traversePath(input, "a.b", PathSemantics::kFieldPath) should produce Types that contain the values produced by the evaluation function. 

      Examples:

      • {a: number}

        with path 'a' produces number

      • {a: number}

        with path 'a.b' produces missing

      • {a: {b: number}} with path 'a' produces {b: number}
      • {a: {b: number}} with path 'a.b' produces number
      • Unknown macro: {a}
        with path 'a.b' produces number|array

      We should refactor the resolveFieldOrigin which might cover most/all of those and remove the function if not necessary. 

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

              Created:
              Updated: