Hive
  1. Hive
  2. HIVE-4174

Round UDF converts BigInts to double

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.11.0
    • Component/s: UDF
    • Labels:
      None
    • Hadoop Flags:
      Incompatible change, Reviewed
    • Release Note:
      The change makes the return type of round function be the same type as that of the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places).

      Description

      Chen Chun pointed out on the hive-user mailing list that round() in Hive 0.10 returns

      select round(cast(1234560 as BIGINT)), round(cast(12345670 as BIGINT)) from test limit 1;
      
      //hive 0.10
      1234560.0  1.234567E7
      

      This is not consistent with MySQL(http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html#function_round)

      which quotes

      The return type is the same type as that of the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places)
      
      1. hive.4174.1.patch-nohcat
        14 kB
        Namit Jain
      2. HIVE-4174.1.patch.txt
        7 kB
        Chun Chen
      3. HIVE-4174.D9687.1.patch
        7 kB
        Phabricator

        Issue Links

          Activity

          Mark Grover created issue -
          Mark Grover made changes -
          Field Original Value New Value
          Link This issue is related to HIVE-3675 [ HIVE-3675 ]
          Chun Chen made changes -
          Attachment HIVE-4174.1.patch.txt [ 12574073 ]
          Chun Chen made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Hadoop Flags Incompatible change [ 10342 ]
          Release Note The change makes the return type of round function be the same type as that of the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places).
          Hide
          Phabricator added a comment -

          chenchun requested code review of "HIVE-4174 [jira] Round UDF converts BigInts to double".

          Reviewers: JIRA

          Round UDF return type be the same type as that of the first argument

          Chen Chun pointed out on the hive-user mailing list that round() in Hive 0.10 returns

          select round(cast(1234560 as BIGINT)), round(cast(12345670 as BIGINT)) from test limit 1;

          //hive 0.10
          1234560.0 1.234567E7

          This is not consistent with MySQL(http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html#function_round)

          which quotes

          The return type is the same type as that of the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places)

          TEST PLAN
          EMPTY

          REVISION DETAIL
          https://reviews.facebook.net/D9687

          AFFECTED FILES
          ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java
          ql/src/test/queries/clientpositive/udf_round_3.q
          ql/src/test/results/clientpositive/udf_round.q.out
          ql/src/test/results/clientpositive/udf_round_3.q.out

          MANAGE HERALD RULES
          https://reviews.facebook.net/herald/view/differential/

          WHY DID I GET THIS EMAIL?
          https://reviews.facebook.net/herald/transcript/23127/

          To: JIRA, chenchun

          Show
          Phabricator added a comment - chenchun requested code review of " HIVE-4174 [jira] Round UDF converts BigInts to double". Reviewers: JIRA Round UDF return type be the same type as that of the first argument Chen Chun pointed out on the hive-user mailing list that round() in Hive 0.10 returns select round(cast(1234560 as BIGINT)), round(cast(12345670 as BIGINT)) from test limit 1; //hive 0.10 1234560.0 1.234567E7 This is not consistent with MySQL( http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html#function_round ) which quotes The return type is the same type as that of the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places) TEST PLAN EMPTY REVISION DETAIL https://reviews.facebook.net/D9687 AFFECTED FILES ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java ql/src/test/queries/clientpositive/udf_round_3.q ql/src/test/results/clientpositive/udf_round.q.out ql/src/test/results/clientpositive/udf_round_3.q.out MANAGE HERALD RULES https://reviews.facebook.net/herald/view/differential/ WHY DID I GET THIS EMAIL? https://reviews.facebook.net/herald/transcript/23127/ To: JIRA, chenchun
          Phabricator made changes -
          Attachment HIVE-4174.D9687.1.patch [ 12575332 ]
          Hide
          Namit Jain added a comment -

          +1

          Show
          Namit Jain added a comment - +1
          Hide
          Phabricator added a comment -

          njain has accepted the revision "HIVE-4174 [jira] Round UDF converts BigInts to double".

          REVISION DETAIL
          https://reviews.facebook.net/D9687

          BRANCH
          HIVE-4174

          ARCANIST PROJECT
          hive

          To: JIRA, njain, chenchun

          Show
          Phabricator added a comment - njain has accepted the revision " HIVE-4174 [jira] Round UDF converts BigInts to double". REVISION DETAIL https://reviews.facebook.net/D9687 BRANCH HIVE-4174 ARCANIST PROJECT hive To: JIRA, njain, chenchun
          Namit Jain made changes -
          Attachment hive.4174.1.patch-nohcat [ 12576732 ]
          Hide
          Namit Jain added a comment -

          Committed. Thanks Chen Chun

          Show
          Namit Jain added a comment - Committed. Thanks Chen Chun
          Namit Jain made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Hadoop Flags Incompatible change [ 10342 ] Incompatible change,Reviewed [ 10342, 10343 ]
          Resolution Fixed [ 1 ]
          Hide
          Mark Grover added a comment -

          Indeed, thanks Chen Chun. And, congratulations on your first Hive commit!

          Show
          Mark Grover added a comment - Indeed, thanks Chen Chun. And, congratulations on your first Hive commit!
          Hide
          Brock Noland added a comment -

          Hey, should this be assigned to Chen Chun?

          Show
          Brock Noland added a comment - Hey, should this be assigned to Chen Chun?
          Hide
          Mark Grover added a comment -

          It should be. Namit Jain can you please add Chen Chun (chenchun dot feed at gmail dot com) to the project contributors list and assign this JIRA to him? Thanks!

          Show
          Mark Grover added a comment - It should be. Namit Jain can you please add Chen Chun (chenchun dot feed at gmail dot com) to the project contributors list and assign this JIRA to him? Thanks!
          Ashutosh Chauhan made changes -
          Assignee Mark Grover [ mgrover ] Chen Chun [ chenchun ]
          Hide
          Hudson added a comment -

          Integrated in Hive-trunk-h0.21 #2043 (See https://builds.apache.org/job/Hive-trunk-h0.21/2043/)
          HIVE-4174 Round UDF converts BigInts to double
          (Chen Chun via namit) (Revision 1463880)

          Result = FAILURE
          namit : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1463880
          Files :

          • /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java
          • /hive/trunk/ql/src/test/queries/clientpositive/udf_round_3.q
          • /hive/trunk/ql/src/test/results/clientpositive/udf_round.q.out
          • /hive/trunk/ql/src/test/results/clientpositive/udf_round_3.q.out
          Show
          Hudson added a comment - Integrated in Hive-trunk-h0.21 #2043 (See https://builds.apache.org/job/Hive-trunk-h0.21/2043/ ) HIVE-4174 Round UDF converts BigInts to double (Chen Chun via namit) (Revision 1463880) Result = FAILURE namit : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1463880 Files : /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java /hive/trunk/ql/src/test/queries/clientpositive/udf_round_3.q /hive/trunk/ql/src/test/results/clientpositive/udf_round.q.out /hive/trunk/ql/src/test/results/clientpositive/udf_round_3.q.out
          Hide
          Hudson added a comment -

          Integrated in Hive-trunk-hadoop2 #138 (See https://builds.apache.org/job/Hive-trunk-hadoop2/138/)
          HIVE-4174 Round UDF converts BigInts to double
          (Chen Chun via namit) (Revision 1463880)

          Result = FAILURE
          namit : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1463880
          Files :

          • /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java
          • /hive/trunk/ql/src/test/queries/clientpositive/udf_round_3.q
          • /hive/trunk/ql/src/test/results/clientpositive/udf_round.q.out
          • /hive/trunk/ql/src/test/results/clientpositive/udf_round_3.q.out
          Show
          Hudson added a comment - Integrated in Hive-trunk-hadoop2 #138 (See https://builds.apache.org/job/Hive-trunk-hadoop2/138/ ) HIVE-4174 Round UDF converts BigInts to double (Chen Chun via namit) (Revision 1463880) Result = FAILURE namit : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1463880 Files : /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFRound.java /hive/trunk/ql/src/test/queries/clientpositive/udf_round_3.q /hive/trunk/ql/src/test/results/clientpositive/udf_round.q.out /hive/trunk/ql/src/test/results/clientpositive/udf_round_3.q.out
          Hide
          Chun Chen added a comment -

          Thanks, Mark Grover, Namit Jain. By the way, I think u noticed a wrong person, Namit Jain is not Namit Jain. And can I assign the issue HIVE-2817 to me. I recently encounter the problem and find the cause of it.

          Show
          Chun Chen added a comment - Thanks, Mark Grover , Namit Jain . By the way, I think u noticed a wrong person, Namit Jain is not Namit Jain . And can I assign the issue HIVE-2817 to me. I recently encounter the problem and find the cause of it.
          Owen O'Malley made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Chun Chen
              Reporter:
              Mark Grover
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development