Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-94191

[SBE] $setWindowFields stage builder should verify that expressions for 'n' are non-constant

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2024-09-16
    • 200

      Create a collection with 

       

      db.test.insert({ "_id" : 0, "level" : 1});
      

       

      and run the incorrect query (because "minN" expects the value to be a constant, not an expression)

      db.test.aggregate( [{"$setWindowFields": {"sortBy": {"num": 1}, "output": {"my_out": {"$minN": {"n": "$level", "input": "$level1"}}}}}])

       

      It will fail compilation with 

      uncaught exception: Error: command failed: {
              "ok" : 0,
              "errmsg" : "undefined slot accessor:1",
              "code" : 4946301,
              "codeName" : "Location4946301"
      }

            Assignee:
            mihai.andrei@mongodb.com Mihai Andrei
            Reporter:
            alberto.massari@mongodb.com Alberto Massari
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: