Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-30564

[Analytics]: Curl return integers as float for AVG

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Minor
    • 6.0.0
    • 6.0.0
    • analytics
    • Untriaged
    • Unknown

    Description

      While running following query as curl

      SELECT name, (SELECT raw avg(s.ratings.Overall) FROM   t.reviews  as s)[0] AS overall_avg_rating FROM   `travel_ds` AS t WHERE `type` = "hotel" ORDER BY overall_avg_rating DESC LIMIT 3

      Response from cbas

      curl -X POST http://10.142.180.102:8095/analytics/service -H 'authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==' -H 'cache-control: no-cache' -H 'content-type: application/json' -d ' {"pretty": true, "client_context_id": "", "timeout": "120s", "$ty":"hotel", "statement": "SELECT name, (SELECT raw avg(s.ratings.Overall) FROM t.reviews as s)[0] AS overall_avg_rating FROM `travel_ds` AS t WHERE `type` = $ty ORDER BY overall_avg_rating DESC LIMIT 3"}'
      {
      "requestID": "506053a9-a8a1-45ea-8f15-fe8cb2f6a6bf",
      "signature": {
      "*": "*"
      },
      "results": [ {
      "name" : "Culloden House Hotel",
      "overall_avg_rating" : 5.0
      }, {
      "name" : "The Bulls Head",
      "overall_avg_rating" : 5.0
      }, {
      "name" : "La Pradella",
      "overall_avg_rating" : 5.0
      } ]
      ,
      "plans":{},
      "status": "success",
      "metrics": {
      "elapsedTime": "393.10119ms",
      "executionTime": "383.792182ms",
      "resultCount": 3,
      "resultSize": 189,
      "processedObjects": 31591
      }
      }

      Response from n1ql

      curl -X POST http://10.142.180.101:8093/query -H 'authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==' -H 'cache-control: no-cache' -H 'content-type: application/json' -H 'postman-token: 026ffa82-6b30-6d1f-5e4c-76707ebedb6e' -d ' {"pretty": true, "client_context_id": "", "timeout": "120s", "$ty":"hotel", "statement": "SELECT name, (SELECT raw avg(s.ratings.Overall) FROM t.reviews as s)[0] AS overall_avg_rating FROM `travel-sample` AS t WHERE `type` = $ty ORDER BY overall_avg_rating DESC LIMIT 3"}'
      {
      "requestID": "3301fa70-6b33-4daa-b1ae-e96f5802ae2e",
      "signature": {
      "name": "json",
      "overall_avg_rating": "json"
      },
      "results": [
      {
      "name": "Culloden House Hotel",
      "overall_avg_rating": 5
      },
      {
      "name": "The Bulls Head",
      "overall_avg_rating": 5
      },
      {
      "name": "La Pradella",
      "overall_avg_rating": 5
      }
      ],
      "status": "success",
      "metrics": {
      "elapsedTime": "361.966217ms",
      "executionTime": "361.839013ms",
      "resultCount": 3,
      "resultSize": 258,
      "sortCount": 917
      }
      }

      Observation : overall_avg_rating is 5.0 in cbas but 5 in n1ql , Also UI shows 5 for both.

      Automated tests are failing because of the difference 

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vikas.chaudhary Vikas Chaudhary
              vikas.chaudhary Vikas Chaudhary
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty