[ 
https://issues.apache.org/jira/browse/HIVE-17077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16099054#comment-16099054
 ] 

Ashutosh Chauhan commented on HIVE-17077:
-----------------------------------------

General principle in such cases is to throw exception at query compile time if 
we can detect illegal argument in udf. But to return null if its runtime since 
there likely it depends on data and we don't fail query for malformed rows.

> Hive should raise StringIndexOutOfBoundsException when LPAD/RPAD len 
> character's value is negative number
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-17077
>                 URL: https://issues.apache.org/jira/browse/HIVE-17077
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Lingang Deng
>            Assignee: Lingang Deng
>            Priority: Minor
>
> lpad(rpad) throw a exception when the second argument a negative number, as 
> follows,
> {code:java}
> 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
> {code}
> Maybe we should return friendly result such as mysql.
> {code:java}
> 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)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to