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

rewriteGroupByMinMax in timeseries doesn't respect collation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0, 6.0.7, 7.0.0-rc4
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v7.0, v6.0, v5.0
    • Hide

      db.createCollection("ts", {timeseries:

      {timeField: 'time', metaField: 'meta'}

      , collation: {locale: "en", numericOrdering: true}})

      ts.insertMany([\{time: ISODate(), meta: 1, value: "10"}, \{time: ISODate(), meta: 1, value: "5"}])

      db.ts.explain().aggregate([\{$group: {_id: "$meta", m: {$max: "$value"}}}], {collation: {locale: 'en', numericOrdering: false}})

      the query returns wrong result of {_id: 1, m: "10" } instead of {_id: 1, m: "5" } which is the max in lexicographic order.

      Show
      db.createCollection("ts", {timeseries: {timeField: 'time', metaField: 'meta'} , collation: {locale: "en", numericOrdering: true }}) ts.insertMany( [\{time: ISODate(), meta: 1, value: "10"}, \{time: ISODate(), meta: 1, value: "5"}] ) db.ts.explain().aggregate( [\{$group: {_id: "$meta", m: {$max: "$value"}}}] , {collation: {locale: 'en', numericOrdering: false }}) the query returns wrong result of {_id: 1, m: "10" } instead of {_id: 1, m: "5" } which is the max in lexicographic order.
    • QI 2023-05-29, QI 2023-06-12

      The rewrite of group with min/max accumulators takes advantage of the min/max being stored for each bucket so it can completely avoid unpacking if the group id is such that it would include whole buckets into each group (currently we do the rewrite only for group by meta field). However, buckets' min/max are computed using the collection's collation and they shouldn't be used if the query specifies a different collation.

            Assignee:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Reporter:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: