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

Inconsistent cast behavior from string to numeric types with regards to leading/trailing spaces

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0
    • Types
    • None

    Description

      select cast(' 1 ' as tinyint), cast(' 1 ' as smallint), cast(' 1 ' as int), cast(' 1 ' as bigint), cast(' 1 ' as float), cast(' 1 ' as double), cast(' 1 ' as decimal(10,2))
      
      NULL    NULL    NULL    NULL    1.0     1.0     1
      

      Looks like integer types (short, int, etc) fail the conversion due to the leading/trailing spaces and return NULL, while float/double/decimal do not. In fact, Decimal used to also return NULL in previous versions up until HIVE-10799.
      Let's try to make this behavior consistent across all of these types, should be simple enough to strip spaces before passing to number formatter.

      Attachments

        1. HIVE-17782.1.patch
          21 kB
          Jason Dere

        Activity

          People

            jdere Jason Dere
            jdere Jason Dere
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: