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

[UDF] n1ql query with advise returns Unexpected identifier

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 7.1.0
    • 7.1.0
    • query
    • 7.1.0-1592
    • Untriaged
    • 1
    • Unknown

    Description

      When trying to create a library with following JS code:

      function advisequery() {
        var iter =  advise select airportname from `travel-sample` where city = 'Grenoble';
        let acc = [];
        for (const row of iter) {
          acc.push(row.advice.adviseinfo.recommended_indexes);
        }
        return {'num_entries': acc.length, 'data': acc};
      } 

      we get error:

      Error while compiling library. Cause:
      compilation failed:
      Exception: SyntaxError: Unexpected identifier
      Location: functions/n1ql.js:1 
      Code: function advisequery() {    var iter =  advise N1QL('select airportname from `travel-sample` where city \u003D \'Grenoble\';', {});    let acc = [];    for (const row of iter) {            acc.push(row.advice.adviseinfo.recommended_indexes);    }    return {'num_entries': acc.length, 'data': acc};} 
      SyntaxError: Unexpected identifier 

      Workaround right now it explicitly wrap query with N1QL e.g.

          var iter =  N1QL("advise select airportname from `travel-sample` where city = 'Grenoble'", {}); 

      Attachments

        For Gerrit Dashboard: MB-49229
        # Subject Branch Project Status CR V

        Activity

          Abhishek Jindal

          We need to allow ADVISE statements as well.

          Can you also validate if you allow "INFER" and "explain" as valid N1QL statements?

          kamini.jagtiani Kamini Jagtiani (Inactive) added a comment - Abhishek Jindal We need to allow ADVISE statements as well. Can you also validate if you allow "INFER" and "explain" as valid N1QL statements?

          Kamini Jagtiani infer and explain work

          pierre.regazzoni Pierre Regazzoni added a comment - Kamini Jagtiani infer and explain work
          kamini.jagtiani Kamini Jagtiani (Inactive) added a comment - Thanks Pierre Regazzoni

          Build couchbase-server-7.1.0-1597 contains eventing-ee commit 3809a9d with commit message:
          MB-49229 : Add advise clause as a valid n1ql statement

          build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.0-1597 contains eventing-ee commit 3809a9d with commit message: MB-49229 : Add advise clause as a valid n1ql statement

          Verified in 7.1.0-1831 

          pierre.regazzoni Pierre Regazzoni added a comment - Verified in 7.1.0-1831 

          People

            pierre.regazzoni Pierre Regazzoni
            pierre.regazzoni Pierre Regazzoni
            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