Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-5352

cast('1.0' as int) returns null

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0
    • Component/s: None
    • Labels:
      None

      Description

      Casting strings to int/smallint/bigint/tinyint yields null if the string isn't a 'pure' integer. '1.0', '2.4' all return null. I think for those cases the cast should return the truncated int (i.e.: if c is string, cast(c as int) should be the same as cast(cast(c as float) as int).

      This is in line with the standard and is the same behavior as mysql and oracle. (postgres and sql server throw error, see first answer here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/af3eff9c-737b-42fe-9016-05da9203a667/oracle-does-understand-cast10-as-int-why-sql-server-does-not)

        Attachments

        1. HIVE-5352.1.patch
          5 kB
          Gunther Hagleitner
        2. HIVE-5352.2.patch
          6 kB
          Gunther Hagleitner
        3. HIVE-5352.3.patch
          6 kB
          Gunther Hagleitner
        4. HIVE-5352.4.patch
          7 kB
          Gunther Hagleitner
        5. HIVE-5352.5.patch
          10 kB
          Gunther Hagleitner

          Activity

            People

            • Assignee:
              hagleitn Gunther Hagleitner
              Reporter:
              hagleitn Gunther Hagleitner
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: