Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7740

Incorrect doc description for nvl2()

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Impala 3.0
    • Impala 3.1.0
    • Docs
    • None
    • ghx-label-8

    Description

      Impala offers the NVL2() function from Oracle. A clearer definition is here:

      The syntax for the NVL2 function in Oracle/PLSQL is:

      NVL2( string1, value_if_not_null, value_if_null )

      Contrast that with the Impala description:

      Enhanced variant of the nvl() function. Tests an expression and returns different result values depending on whether it is NULL or not. If the first argument is NULL, returns the second argument. If the first argument is not NULL, returns the third argument. Equivalent to the nvl2() function from Oracle Database.

      (Emphasis added.) The description is exactly backward. To see this:

      select n, nvl2(n, 10, 20) from ints;
      +------+---------------------------+
      | n    | if(n is not null, 10, 20) |
      +------+---------------------------+
      | NULL | 20                        |
      | 0    | 10                        |
      +------+---------------------------+
      

      Hence, the implementation follows Oracle, the documentation is wrong.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            arodoni Alexandra Rodoni
            Paul.Rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment