v3.6 breaks contract

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.7.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      After upgrading dotnet driver from 3.5.2 to 3.6.0, it fails to evaluate some previously working aggregations for timeseries collection.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      How to Reproduce

      Model: 
      {

      "t" : ISODate("2023-03-01T00:00:00.000+0000"),

      "m" : {

      "i" : 1796183759,

      "t" : "33333333-3333-3333-3333-333333333333"

      {color:#dfdfdf}},

      "_id" : ObjectId("698a351c81559bc74e2cb2c9"),

      "p" : { "$numberDecimal" : "1.01" {color:#dfdfdf}},

      "o" : ISODate("2026-02-09T19:27:22.590+0000")

      {color:#dfdfdf}}
      h4. t = Timestamp
      o = DataTimestamp
      p = Price
      h4.
      LINQ Query

      GetCollection().AsQueryable()
          .Where(filter)
          .GroupBy(g => g.Timestamp, v => v)
          .Select(g => g.OrderBy(o => o.DataTimestamp).Last())
          .OrderBy(o => o.Timestamp)
          .GroupBy(g => g.Timestamp.Truncate(DateTimeUnit.Minute, 15), v => v)
          .Select(g => new AggregatedPriceSeriesItem
          {         Timestamp = g.First().Timestamp,         Price = g.Average(i => i.Price)     })
          .OrderBy(o => o.Timestamp);
      h4. Additional Background
      The difference is in how the Timestamp = g.First().Timestamp is generated

      v3.5.2 working aggregation
      _db
      .getCollection("...").aggregate([{ "$match" : { "m.t" : "33333333-3333-3333-3333-333333333333", "m.i" : 1796183759, "t" : { "$gte" : { "$date" : "2023-03-01T00:00:00Z" {color:#dfdfdf}}, "$lt" : { "$date" : "2023-03-02T00:00:00Z" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$group" : { "_id" : "$t", "_elements" : { "$push" : "$$ROOT" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$project" : { "_v" : { "$arrayElemAt" : [{ "$sortArray" : { "input" : "$_elements", "sortBy" : { "o" : 1 {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, -1] {color:#dfdfdf}}, "_id" : 0 {color:#dfdfdf}} {color:#dfdfdf}}, { "$sort" : { "_v.t" : 1 {color:#dfdfdf}} {color:#dfdfdf}}, { "$group" : { "_id" : { "$dateTrunc" : { "date" : "$_v.t", "unit" : "hour" {color:#dfdfdf}} {color:#dfdfdf}}, "__agg0" : { "$first" : "$_v.t" {color:#dfdfdf}}, "__agg1" : { "$avg" : "$_v.p" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$project" : { "t" : "$__agg0", "p" : "$__agg1", "_id" : 0 {color:#dfdfdf}} {color:#dfdfdf}}, { "$sort" : { "t" : 1 {color:#dfdfdf}} {color:#dfdfdf}}])_

      v3.6 not-working aggregation (returns empty result)

      db.getCollection("PriceSeries").aggregate([{ "$match" : { "m.t" : "33333333-3333-3333-3333-333333333333", "m.i" : -1506222593, "t" : { "$gte" : { "$date" : "2023-03-01T00:00:00Z" {color:#dfdfdf}}, "$lt" : { "$date" : "2023-03-02T00:00:00Z" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$group" : { "_id" : "$t", "_elements" : { "$push" : "$$ROOT" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$project" : { "_v" : { "$arrayElemAt" : [{ "$sortArray" : { "input" : "$_elements", "sortBy" : { "o" : 1 {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, -1] {color:#dfdfdf}}, "_id" : 0 {color:#dfdfdf}} {color:#dfdfdf}}, { "$sort" : { "_v.t" : 1 {color:#dfdfdf}} {color:#dfdfdf}}, { "$group" : { "_id" : { "$dateTrunc" : { "date" : "$_v.t", "unit" : "hour" {color:#dfdfdf}} {color:#dfdfdf}}, "__agg0" : { "$first" : "$t" {color:#dfdfdf}}, "__agg1" : { "$avg" : "$_v.p" {color:#dfdfdf}} {color:#dfdfdf}} {color:#dfdfdf}}, { "$project" : { "t" : "$__agg0", "p" : "$__agg1", "_id" : 0 {color:#dfdfdf}} {color:#dfdfdf}}, { "$sort" : { "t" : 1 {color:#dfdfdf}} {color:#dfdfdf}}])

            Assignee:
            Adelin Mbida Owona
            Reporter:
            Tomáš Hřebíček
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: