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

[AGGREGATE] aggregate inside a LETTING query returns an error

    XMLWordPrintable

Details

    • Bug
    • Resolution: User Error
    • Major
    • 5.5.0
    • 5.5.0
    • query
    • None
    • 5.5.0-1593
    • Untriaged
    • No

    Description

      This query:

      select meta().id,total from default GROUP BY meta().id LETTING total = (SELECT RAW SUM(VMs.memory) FROM default.VMs AS VMs)[0] order by meta().id limit 10

      Returns this error:

      [
      {
      "code": 4210,
      "msg": "Expression must be a group key or aggregate: ((select raw sum((`VMs`.`memory`)) from (`default`.`VMs`) as `VMs`)[0])",
      "query_from_user": "select meta().id,total from default GROUP BY meta().id LETTING total = (SELECT RAW SUM(VMs.memory) FROM default.VMs AS VMs)[0] order by meta().id limit 10"
      }
      ]

      This used to pass but given the numbering change it was a large number of builds ago. 1563, have not narrowed down the builds any further. Logs are attached

       

      Here is a sample doc, there is only a primary index:

      {
      "tasks": [
      {
      "Marketing": [
      {
      "region2": "International",
      "region1": "South"
      },
      {
      "region2": "South"
      }
      ],
      "Developer": [
      "IOS",
      "Indexing"
      ]
      },
      "Sales",
      "QA"
      ],
      "name": [
      {
      "FirstName": "employeefirstname-9"
      },
      {
      "MiddleName": "employeemiddlename-9"
      },
      {
      "LastName": "employeelastname-9"
      }
      ],
      "address": [
      [
      {
      "city": "Delhi"
      },
      {
      "street": "12th street"
      }
      ],
      [
      {
      "country": "EUROPE",
      "apartment": 123
      }
      ]
      ],
      "email": "9-mail@couchbase.com",
      "mutated": 0,
      "hobbies": {
      "hobby": [
      {
      "sports": [
      "Badminton",
      "Football",
      "Basketball"
      ]
      },
      {
      "dance": [
      "hip hop",
      "bollywood",
      "contemporary"
      ]
      },
      "art"
      ]
      },
      "department": "Support",
      "join_yr": [
      2013,
      2015,
      2012
      ],
      "_id": "query-testemployee10153.1877827-0",
      "VMs": [
      {
      "RAM": 10,
      "os": "ubuntu",
      "name": "vm_10",
      "memory": 10
      },
      {
      "RAM": 10,
      "os": "windows",
      "name": "vm_11",
      "memory": 10
      },
      {
      "RAM": 10,
      "os": "centos",
      "name": "vm_12",
      "memory": 10
      },
      {
      "RAM": 10,
      "os": "macos",
      "name": "vm_13",
      "memory": 10
      }
      ]
      }
      

      You can reproduce the error by running this testrunner command:
      ./testrunner -i /tmp/testexec.27903.ini -p gsi_type=memory_optimized,nodes_init=2,doc-per-day=6 -t tuqquery.tuq_subquery.QuerySubqueryTests.test_subquery_letting,index_type=GSI,array_indexing=True

      Attachments

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

        Activity

          People

            ajay.bhullar Ajay Bhullar
            ajay.bhullar Ajay Bhullar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty