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

Hive should raise StringIndexOutOfBoundsException when LPAD/RPAD len character's value is negative number

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      lpad(rpad) throw a exception when the second argument a negative number, as follows,

      hive> select lpad("hello", -1 ,"h");
      FAILED: StringIndexOutOfBoundsException String index out of range: -1
      hive> select rpad("hello", -1 ,"h");
      FAILED: StringIndexOutOfBoundsException String index out of range: -1
      

      Maybe we should return friendly result such as mysql.

      mysql> select lpad("hello", -1 ,"h");
      +----------------------+
      | lpad("hello", -1 ,"h") |
      +----------------------+
      | NULL                 |
      +----------------------+
      1 row in set (0.00 sec)
      
      mysql> select rpad("hello", -1 ,"h");
      +----------------------+
      | rpad("hello", -1 ,"h") |
      +----------------------+
      | NULL                 |
      +----------------------+
      1 row in set (0.00 sec)
      

      Attachments

        Activity

          People

            chitin Lingang Deng
            chitin Lingang Deng
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m