Pass targetNode's ExpCtx info when creating CanonicalQuery in predicate inference

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      During JOO predicate inference, propagateSingleTablePredicate creates a fresh non-cloned ExpressionContext (carrying only ns and opCtx) and replaces targetNode.accessPath with a new CQ built using this new ExpCtx. All other fields from the original ExpCtx such as collator, explain mode, etc. are lost.

      If this node gets selected as reordered.baseNode, SBE lowers using this stripped ExpCtx. For example, expCtx.getCollatorShared() would return null, effectively ignoring collation in SBE. We should investigate whether this is actually an issue and also audit the other fields used in SBE.

      The fix is to clone the original ExpCtx via makeCopyFromExpressionContext (perhaps we can re-use the one that stores the PathArrayness information). We would also need to explicitly set inLookup to false on the clone. Foreign node ExpCtx}}s have inLookup=true (set in {{DocumentSourceLookup constructor), which disables CQ simplification.

            Assignee:
            Projjal Chanda
            Reporter:
            Naafiyan Ahmed
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: