You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/12 08:00:00 UTC

[jira] [Commented] (HIVE-17077) Hive should raise StringIndexOutOfBoundsException when LPAD/RPAD len character's value is negative number

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

ASF GitHub Bot commented on HIVE-17077:
---------------------------------------

GitHub user chitin opened a pull request:

    https://github.com/apache/hive/pull/203

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

    [HIVE-17077] Hive should raise StringIndexOutOfBoundsException when LPAD/RPAD len character's value is negative number
    - return null when len character's value is negative number
    
    https://issues.apache.org/jira/browse/HIVE-17077

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/chitin/hive hive17077

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/hive/pull/203.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #203
    
----
commit 8715915839f76f6d60d6b40400d3bb826cbeb8b5
Author: chitin <ch...@gmail.com>
Date:   2017-07-12T07:56:47Z

    HIVE-17077 Hive should raise StringIndexOutOfBoundsException when LPAD/RPAD len character's value is negative number
    - Add len judgment logic

----


> 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)