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

Error: function field-access-by-name expects its 1st input parameter to be type object but the actual input type is string

    XMLWordPrintable

Details

    • Untriaged
    • No
    • CX Sprint 111, CX Sprint 112, CX Sprint 114, CX Sprint 115, CX Sprint 141, CX Sprint 142

    Description

      Original Query:

      SELECT name FROM default_shadow WHERE ANY x IN ["Support","Management"] SATISFIES job_title = x END ORDER BY name;
      

      This works fine in N1QL but cbas throws an error.
      If we refer job_title with dataset name it works fine, without that query parser considers it as string.

      Modified Query:

      SELECT name FROM default_shadow WHERE ANY x IN ["Support","Management"] SATISFIES default_shadow.job_title = x END ORDER BY name;
      

      Here job_title is of type String in the document.

      Another example is:

      SELECT name,email FROM default_shadow WHERE (ANY skill IN default_shadow.skills SATISFIES skill = 'skill2010' END)
      

      Here skills is an json array and comparison is happening between two strings as it was in the previous case and it is working properly.

      Sample Document:

      {
        "mutated": 0,
        "test_rate": 11.11,
        "join_mo": 11,
        "join_day": 21,
        "skills": [
          "skill2010",
          "skill2011"
        ],
        "hikes": [
          20,
          10,
          15
        ],
        "permanent": 1,
        "tasks_points": {
          "task1": 1,
          "task2": 1
        },
        "join_yr": 2010,
        "name": "employee-21",
        "_id": "query-testemployee58360.6484454-0",
        "job_title": "Support",
        "VMs": [
          {
            "name": "vm_11",
            "memory": 11,
            "os": "ubuntu",
            "RAM": 11
          },
          {
            "name": "vm_12",
            "memory": 11,
            "os": "windows",
            "RAM": 11
          }
        ],
        "email": "21-mail@couchbase.com"
      }
      

      Attachments

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

        Activity

          The current result is

          [
            {
              "code": 25000,
              "msg": "Internal error",
              "query_from_user": "SELECT name FROM default_shadow WHERE ANY x IN [\"Support\",\"Management\"] SATISFIES job_title = x END ORDER BY name;"
            }
          ]
          

          and the logs show

          2018-10-17T18:54:33.082-07:00 INFO CBAS.translator.QueryTranslator [QueryTranslator] ASX1038: Illegal state. $x
          org.apache.asterix.common.exceptions.CompilationException: ASX1038: Illegal state. $x
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.translateVariableRef(LangExpressionToPlanTranslator.java:812) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translateVariableRef(SqlppExpressionToPlanTranslator.java:659) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:762) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:168) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.common.expression.CallExpr.accept(CallExpr.java:62) ~[asterix-lang-common.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.langExprToAlgExpression(LangExpressionToPlanTranslator.java:1490) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translateInOperatorWithStaticList(SqlppExpressionToPlanTranslator.java:946) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:870) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.common.expression.QuantifiedExpression.accept(QuantifiedExpression.java:77) ~[asterix-lang-common.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.langExprToAlgExpression(LangExpressionToPlanTranslator.java:1490) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:1347) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:168) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.common.clause.WhereClause.accept(WhereClause.java:53) ~[asterix-lang-common.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:250) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.sqlpp.struct.SetOperationInput.accept(SetOperationInput.java:57) ~[asterix-lang-sqlpp.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:206) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.sqlpp.clause.SelectSetOperation.accept(SelectSetOperation.java:47) ~[asterix-lang-sqlpp.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:185) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.sqlpp.expression.SelectExpression.accept(SelectExpression.java:55) ~[asterix-lang-sqlpp.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:158) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.lang.common.statement.Query.accept(Query.java:94) ~[asterix-lang-common.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.translate(LangExpressionToPlanTranslator.java:313) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translate(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.LangExpressionToPlanTranslator.translate(LangExpressionToPlanTranslator.java:303) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translate(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693]
          	at org.apache.asterix.api.common.APIFramework.compileQuery(APIFramework.java:219) ~[asterix-app.jar:6.0.0-1693]
          

          We'll need to improve the error message.

          till Till Westmann added a comment - The current result is [ { "code": 25000, "msg": "Internal error", "query_from_user": "SELECT name FROM default_shadow WHERE ANY x IN [\"Support\",\"Management\"] SATISFIES job_title = x END ORDER BY name;" } ] and the logs show 2018-10-17T18:54:33.082-07:00 INFO CBAS.translator.QueryTranslator [QueryTranslator] ASX1038: Illegal state. $x org.apache.asterix.common.exceptions.CompilationException: ASX1038: Illegal state. $x at org.apache.asterix.translator.LangExpressionToPlanTranslator.translateVariableRef(LangExpressionToPlanTranslator.java:812) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translateVariableRef(SqlppExpressionToPlanTranslator.java:659) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:762) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:168) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.common.expression.CallExpr.accept(CallExpr.java:62) ~[asterix-lang-common.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.langExprToAlgExpression(LangExpressionToPlanTranslator.java:1490) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translateInOperatorWithStaticList(SqlppExpressionToPlanTranslator.java:946) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:870) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.common.expression.QuantifiedExpression.accept(QuantifiedExpression.java:77) ~[asterix-lang-common.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.langExprToAlgExpression(LangExpressionToPlanTranslator.java:1490) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:1347) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.visit(LangExpressionToPlanTranslator.java:168) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.common.clause.WhereClause.accept(WhereClause.java:53) ~[asterix-lang-common.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:250) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.sqlpp.struct.SetOperationInput.accept(SetOperationInput.java:57) ~[asterix-lang-sqlpp.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:206) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.sqlpp.clause.SelectSetOperation.accept(SelectSetOperation.java:47) ~[asterix-lang-sqlpp.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:185) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.sqlpp.expression.SelectExpression.accept(SelectExpression.java:55) ~[asterix-lang-sqlpp.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:158) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.visit(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.lang.common.statement.Query.accept(Query.java:94) ~[asterix-lang-common.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.translate(LangExpressionToPlanTranslator.java:313) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translate(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.LangExpressionToPlanTranslator.translate(LangExpressionToPlanTranslator.java:303) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.translator.SqlppExpressionToPlanTranslator.translate(SqlppExpressionToPlanTranslator.java:128) ~[asterix-algebra.jar:6.0.0-1693] at org.apache.asterix.api.common.APIFramework.compileQuery(APIFramework.java:219) ~[asterix-app.jar:6.0.0-1693] We'll need to improve the error message.

          The "Illegal State" error is tracked by open source issue:
          https://issues.apache.org/jira/browse/ASTERIXDB-2527

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - The "Illegal State" error is tracked by open source issue: https://issues.apache.org/jira/browse/ASTERIXDB-2527

          Illegal State error has been fixed.

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - Illegal State error has been fixed.

          Getting the error:

          [
            {
              "code": 24057,
              "msg": "Type mismatch: expected value of type object, but got the value of type string (in line 1, at column 71)",
              "query_from_user": "SELECT name FROM ds WHERE ANY x IN [\"Support\",\"Management\"] SATISFIES job_title = x END ORDER BY name;"
            }
          ]
          

          ritesh.agarwal Ritesh Agarwal added a comment - Getting the error: [ { "code": 24057, "msg": "Type mismatch: expected value of type object, but got the value of type string (in line 1, at column 71)", "query_from_user": "SELECT name FROM ds WHERE ANY x IN [\"Support\",\"Management\"] SATISFIES job_title = x END ORDER BY name;" } ]

          This error is expected in Analytics because of the current identifier resolution rules.

          Inside SOME/ANY all unqualified identifiers are resolved as field reference to the variable defined by SOME/ANY. In this case in 'ANY x IN [... ]SATISFIES job_title = x'  job_title is resolved as x.job_title  . This leads to Type mismatch error because x is bound to a string, not an object.

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - This error is expected in Analytics because of the current identifier resolution rules. Inside SOME/ANY all unqualified identifiers are resolved as field reference to the variable defined by SOME/ANY. In this case in 'ANY x IN [... ] SATISFIES job_title = x'  job_title is resolved as x.job_title  . This leads to Type mismatch error because x is bound to a string, not an object.

          People

            dmitry.lychagin Dmitry Lychagin (Inactive)
            ritesh.agarwal Ritesh Agarwal
            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