• 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

      Inclusion projections, exclusion projections and computed assignments have different effects on scalar, missing, object and array prefixes.

      Prefix type inference needs to distinguish these operations rather than retain only whether a prefix can be an array. The current expectations lose known scalar types, retain missing alternatives for fields that are guaranteed to exist, and retain array alternatives after a later match rules out prefix arrays.

      Inclusion

      [\{$set: {p: 1}}, \{$project: {'p.a': 1}}]

      We infer the type of p as ~array, when it should be missing. Including p.a removes the scalar prefix p.

      Exclusion

      [\{$set: {p: 1}}, \{$project: {'p.a': 0}}]

      We infer the type of p as ~array, when we should retain its known integer type. Excluding p.a leaves the scalar prefix p unchanged.

      Computed

      [\{$set: {p: 1}}, \{$project: {'p.a': '$b'}}]

      We infer the type of p as ~array, when it should be object. And the type of p.a we set as maybe-missing right now, treating it the same as the inclusion case.

      The computed assignment replaces the scalar prefix p with an object, even when b is missing.

      Suggested solution

      I think we can expand the ModifiedPathPolicy, which currently has kPreserveArrays and kEnsureObjects. The kPreserveArrays can split into kPreserveArraysAndScalars (exclusion), kPreserveArraysRemoveScalars (inclusion), kPreserveArraysOrEnsureObjects (computed). 

      This will let us model these types without hardcoding a dependency on the TransformerInterface::TransformerType.

      The alternative is to special case SingleDocumentTransformation further and then the TransformerType types.

       

       

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

              Created:
              Updated: