Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3120

MongoAdapterTest.testGroupByAvgSumCount fails due the order of sort query

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.19.0
    • 1.21.0
    • mongodb-adapter
    • None

    Description

      The MongoAdapterTest.testGroupByAvgSumCount fails because $sort operator does not appear at the middle of the query but in the end.

      org.junit.ComparisonFailure:
      expected and actual Mongo queries (pipelines) do not match expected:<...$project" : {
          "[POP" : "$pop",
          "STATE" : "$state"
        }
      }
      {
        "$group" : {
          "_id" : "$STATE",
          "_1" : {
            "$sum" : "$POP"
          },
          "_2" : {
            "$sum" : {
              "$cond" : [{
                  "$eq" : ["POP", null]
                }, 0, 1]
            }
          }
        }
      }
      {
        "$project" : {
          "STATE" : "$_id",
          "_1" : "$_1",
          "_2" : "$_2"
        }
      }
      {
        "$sort" : {
          "STATE" : 1
        }
      }
      {
        "$project" : {
          "STATE" : 1,
          "A" : {
            "$divide" : [{
                "$cond" : [{
                    "$eq" : ["$_2", {
                        "$literal" : 0
                      }]
                  }, null, "$_1"]
              }, "$_2"]
          },
          "S" : {
            "$cond" : [{
                "$eq" : ["$_2", {
                    "$literal" : 0
                  }]
              }, null, "$_1"]
          },
          "C" : "$_2"]
        }
      }> but was:<...$project" : {
          "[STATE" : "$state",
          "POP" : "$pop"
        }
      }
      {
        "$group" : {
          "_id" : "$STATE",
          "_1" : {
            "$sum" : "$POP"
          },
          "_2" : {
            "$sum" : {
              "$cond" : [{
                  "$eq" : ["POP", null]
                }, 0, 1]
            }
          }
        }
      }
      {
        "$project" : {
          "STATE" : "$_id",
          "_1" : "$_1",
          "_2" : "$_2"
        }
      }
      {
        "$project" : {
          "STATE" : 1,
          "A" : {
            "$divide" : [{
                "$cond" : [{
                    "$eq" : ["$_2", {
                        "$literal" : 0
                      }]
                  }, null, "$_1"]
              }, "$_2"]
          },
          "S" : {
            "$cond" : [{
                "$eq" : ["$_2", {
                    "$literal" : 0
                  }]
              }, null, "$_1"]
          },
          "C" : "$_2"
        }
      }
      {
        "$sort" : {
          "STATE" : 1]
        }
      }>
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            zabetak Stamatis Zampetakis
            zabetak Stamatis Zampetakis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment