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

[UDF] ANALYZE return Unexpected token in JS udf

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.1.0
    • 7.1.0
    • js-evaluator, query
    • 7.1.0-1650
    • Untriaged
    • 1
    • Unknown

    Description

      Cannot use ANALYZE in javascript UDF:

      # curl -s -k -X POST http://172.23.104.90:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function analyze_default() {            var query = ANALYZE default(job_title);            var acc = [];            for (const row of query) {                acc.push(row);            }            return acc;}'
      Error while compiling library. Cause:
      compilation failed:
      Exception: SyntaxError: Unexpected token 'default'
      Location: functions/n1ql.js:1 
      Code: function analyze_default() {            var query = ANALYZE default(job_title);            var acc = [];            for (const row of query) {                acc.push(row);            }            return acc;}
      SyntaxError: Unexpected token 'default' 

      Works ok with UPDATE STATS:

      # curl -s -k -X POST http://172.23.104.90:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function analyze_default() {            var query = UPDATE STATISTICS FOR default(job_title);            var acc = [];            for (const row of query) {                acc.push(row);            }            return acc;}'
      {status: "OK"}

      Attachments

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

        Activity

          People

            pierre.regazzoni Pierre Regazzoni
            pierre.regazzoni Pierre Regazzoni
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty