Base collection fields discarded when right subtree only has embedded fields

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2026-03-16, QE 2026-03-02
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Examples of problematic QSNs (same one but with left & right children of root swapped also has the same problem):

      HASH_JOIN_EMBEDDING [b = b]
      leftEmbeddingField: "none"
      rightEmbeddingField: "y"
        |  |
        |  COLLSCAN [test.a]
        |  direction: "forward"
        |
        HASH_JOIN_EMBEDDING [a = x.a]
        leftEmbeddingField: "none"
        rightEmbeddingField: "none"
        |  |
        |  HASH_JOIN_EMBEDDING [c = c]
        |  leftEmbeddingField: "z"
        |  rightEmbeddingField: "x"
        |  |  |
        |  |  COLLSCAN [test.a]
        |  |  direction: "forward"
        |  |
        |  COLLSCAN [test.a]
        |  direction: "forward"
        |
        COLLSCAN [test.a]
        direction: "forward"

      Corresponding SBE plan:

      {
        slots: '$$RESULT=s21 env: { s16 = Nothing (nothing) }',
        stages: '[7] project [s21 = makeBsonObj(MakeObjSpec([y = Set(0), z = Set(1), x = Set(2)], Open, NewObj, 0), s16, s1, s8, s11)] \n' +
          '[7] hj \n' +
          '    left [s20] [s7, s11, s8] \n' +
          '        [7] project [s20 = (s7 ?: null)] \n' +
          '        [6] hj \n' +
          '            left [s18] [s11, s8] \n' +
          '                [6] project [s18 = (getField(s11, "a") ?: null)] \n' +
          '                [5] hj \n' +
          '                    left [s15] [s11, s13] \n' +
          '                        [5] project [s15 = (s13 ?: null)] \n' +
          '                        [4] scan generic [s11 = record, s12 = recordId] [s13 = c] @"36f88150-1f98-4603-b5d5-9588d08723f1" \n' +
          '                    right [s14] [s8, s10] \n' +
          '                        [5] project [s14 = (s10 ?: null)] \n' +
          '                        [3] scan generic [s8 = record, s9 = recordId] [s10 = c] @"36f88150-1f98-4603-b5d5-9588d08723f1" \n' +
          '            right [s17] [s4, s6, s7] \n' +
          '                [6] project [s17 = (s6 ?: null)] \n' +
          '                [2] scan generic [s4 = record, s5 = recordId] [s6 = a, s7 = b] @"36f88150-1f98-4603-b5d5-9588d08723f1" \n' +
          '    right [s19] [s1, s3] \n' +
          '        [7] project [s19 = (s3 ?: null)] \n' +
          '        [1] scan generic [s1 = record, s2 = recordId] [s3 = b] @"36f88150-1f98-4603-b5d5-9588d08723f1" \n'
      }

      We can see that s16 (the "nothing" slot) is used as the root slot, when in fact we should be using s4. This results in fields from the base collection not being included in the output.

            Assignee:
            Alberto Massari
            Reporter:
            Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: