hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carter Shanklin (JIRA)" <>
Subject [jira] [Created] (HIVE-17030) HPL/SQL: Many cast operations are ignored without warning or notice.
Date Tue, 04 Jul 2017 21:22:01 GMT
Carter Shanklin created HIVE-17030:

             Summary: HPL/SQL: Many cast operations are ignored without warning or notice.
                 Key: HIVE-17030
             Project: Hive
          Issue Type: Bug
          Components: hpl/sql
            Reporter: Carter Shanklin
            Priority: Critical

This bug is part of a series of issues and surprising behavior I encountered writing a reporting
script that would aggregate values and give rows different classifications based on an the
aggregate. Addressing some or all of these issues would make HPL/SQL more accessible to newcomers.

Consider this code:
  val1d := cast('10.0' as double);
  val2d := cast('5.0' as double);
  declare val1i int = 5;
  declare val2i int = 5;
  val1i = val1d;
  diff := val1i - val2i;

What is the value of diff? You might think it is 5 but in fact it is 0. Why? Because when
you attempt to assign val1i to val1d, this code in is executed:

    else if (type == Type.BIGINT) {
      if (val.type == Type.STRING) {
        value = Long.parseLong((String)val.value);
    else if (type == Type.DECIMAL) {

Since there is no case for assigning a double to a bigint, the expression is essentially ignored
and the value remains the same. This behavior leads to many surprising results.

It would be best if HPL/SQL could re-use the cast code from Hive since there are a lot of
cases to consider.

Version = 3.0.0-SNAPSHOT r71f52d8ad512904b3f2c4f04fe39a33f2834f1f2

This message was sent by Atlassian JIRA

View raw message