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)