$lastN ordering issue

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 6.0.1
    • Component/s: None
    • None
    • ALL
    • Hide

      Simply click the copy buttons for the data and the pipeline and see the results.

      Show
      Simply click the copy buttons for the data and the pipeline and see the results.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If I run the example here:  https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#computing-n-based-on-the-group-key-for–group, I get the following results:

      { "_id" : \{ "gameId" : "G1" }

      , "gamescores" : [ 33, 99, 1 ] }

      { "_id" : \{ "gameId" : "G2" }

      , "gamescores" : [ 80 ] }

      But the docs show, correctly, that for G2 there should be only a 10 there.  I'm literally using the 'copy' action on the page and pasting in to my local shell and getting those results.  Am I tripping or is there a bug here? 

      server build info as follows:

      db.serverBuildInfo()
      {
              "version" : "6.0.1",
              "gitVersion" : "32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b",
              "targetMinOS" : "Windows 7/Windows Server 2008 R2",
              "modules" : [ ],
              "allocator" : "tcmalloc",
              "javascriptEngine" : "mozjs",
              "sysInfo" : "deprecated",
              "versionArray" : [
                      6,
                      0,
                      1,
                      0
              ],
              "openssl" :

      {                 "running" : "Windows SChannel"         }

      ,
              "buildEnvironment" :

      {                 "distmod" : "windows",                 "distarch" : "x86_64",                 "cc" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31107 for x64",                 "ccflags" : "/nologo /WX /FImongo/platform/basic.h /EHsc /W3 /wd4068 /wd4244 /wd4267 /wd4290 /wd4351 /wd4355 /wd4373 /wd4800 /wd4251 /wd4291 /we4013 /we4099 /we4930 /errorReport:none /MD /O2 /Oy- /bigobj /utf-8 /permissive- /Zc:__cplusplus /Zc:sizedDealloc /volatile:iso /diagnostics:caret /std:c++17 /Gw /Gy /Zc:inline",                 "cxx" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31107 for x64",                 "cxxflags" : "/TP",                 "linkflags" : "/nologo /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /OPT:REF",                 "target_arch" : "x86_64",                 "target_os" : "windows",                 "cppdefines" : "SAFEINT_USE_INTRINSICS 0 PCRE_STATIC NDEBUG BOOST_ALL_NO_LIB _UNICODE UNICODE _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS _CONSOLE _CRT_SECURE_NO_WARNINGS _ENABLE_EXTENDED_ALIGNED_STORAGE _SCL_SECURE_NO_WARNINGS _WIN32_WINNT 0x0A00 BOOST_USE_WINAPI_VERSION 0x0A00 NTDDI_VERSION 0x0A000000 BOOST_THREAD_VERSION 5 BOOST_THREAD_USES_DATETIME BOOST_SYSTEM_NO_DEPRECATED BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS BOOST_ENABLE_ASSERT_DEBUG_HANDLER BOOST_LOG_NO_SHORTHAND_NAMES BOOST_LOG_USE_NATIVE_SYSLOG BOOST_LOG_WITHOUT_THREAD_ATTR ABSL_FORCE_ALIGNED_ACCESS"         }

      ,
              "bits" : 64,
              "debug" : false,
              "maxBsonObjectSize" : 16777216,
              "storageEngines" : [
                      "devnull",
                      "ephemeralForTest",
                      "wiredTiger"
              ],
              "ok" : 1
      }

            Assignee:
            Yuan Fang
            Reporter:
            Justin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: