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

"Select IFINF(2,1/0);" return 2 in N1QL but arithmetic error in analytics.

    XMLWordPrintable

Details

    • Untriaged
    • No
    • CX Sprint 96, CX Sprint 97, CX Sprint 112, CX Sprint 113

    Description

      As per definition in N1QL for IFINF(expression1, expression2, ...):
      Returns first non-MISSING, non-Inf number. Returns MISSING or NULL if a non-number input is encountered first.

      Select IFINF(2,1/0); In this statement the first input is a number and second is an infinite value.
      N1QL returns 2 but analytics gives an error:

      [

      { "code": 1, "msg": "Exception: java.lang.ArithmeticException: Division by Zero.", "query_from_user": "select IFINF(2,1/0)" }

      ]

      Attachments

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

        Activity

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - open source issue: https://issues.apache.org/jira/browse/ASTERIXDB-2346  

          If the query is slightly twisted to: Select IFINF(1/0,2)
          N1QL:
          [

          { "$1": null }

          ]
          CBAS:
          [

          { "code": 1, "msg": "ASX0034: Division by Zero.", "query_from_user": "Select IFINF(1/0,2)" }

          ]

          As per the definition: Returns first non-MISSING, non-Inf number. Returns MISSING or NULL if a non-number input is encountered first.
          Reference: https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/condfunnum.html

          ritesh.agarwal Ritesh Agarwal added a comment - If the query is slightly twisted to: Select IFINF(1/0,2) N1QL: [ { "$1": null } ] CBAS: [ { "code": 1, "msg": "ASX0034: Division by Zero.", "query_from_user": "Select IFINF(1/0,2)" } ] As per the definition: Returns first non-MISSING, non-Inf number. Returns MISSING or NULL if a non-number input is encountered first. Reference: https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/condfunnum.html

          For second query (IFINF(1/0,2)) CBAS currently returns 2, while N1QL returns NULL. The difference is due to the division operator. In N1QL division by 0 returns NULL, so IFINF returns it. In CBAS division by 0 returns INF and IFINF() function skips over it and returns the second argument (2).

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - For second query (IFINF(1/0,2)) CBAS currently returns 2, while N1QL returns NULL. The difference is due to the division operator. In N1QL division by 0 returns NULL, so IFINF returns it. In CBAS division by 0 returns INF and IFINF() function skips over it and returns the second argument (2).

          The open source issue for tracking division by 0 issue is: https://issues.apache.org/jira/browse/ASTERIXDB-2423

          dmitry.lychagin Dmitry Lychagin (Inactive) added a comment - The open source issue for tracking division by 0 issue is: https://issues.apache.org/jira/browse/ASTERIXDB-2423

          Build couchbase-server-6.5.0-1127 contains asterix-opt commit c69c4f1 with commit message:
          MB-28771: Remove error code mapping for division by zero

          build-team Couchbase Build Team added a comment - Build couchbase-server-6.5.0-1127 contains asterix-opt commit c69c4f1 with commit message: MB-28771 : Remove error code mapping for division by zero

          Build couchbase-server-6.0.0-1395 contains asterix-opt commit c69c4f1 with commit message:
          MB-28771: Remove error code mapping for division by zero

          build-team Couchbase Build Team added a comment - Build couchbase-server-6.0.0-1395 contains asterix-opt commit c69c4f1 with commit message: MB-28771 : Remove error code mapping for division by zero

          Verified on build 6.0.0-1491.

          ritesh.agarwal Ritesh Agarwal added a comment - Verified on build 6.0.0-1491.

          People

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