You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Min Zhou (JIRA)" <ji...@apache.org> on 2009/05/24 15:06:45 UTC

[jira] Created: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

[GenericUDF] new string function ELT(N,str1,str2,str3,...) 
-----------------------------------------------------------

                 Key: HIVE-512
                 URL: https://issues.apache.org/jira/browse/HIVE-512
             Project: Hadoop Hive
          Issue Type: New Feature
          Components: Query Processor
    Affects Versions: 0.4.0
            Reporter: Min Zhou
            Assignee: Min Zhou
             Fix For: 0.4.0


ELT(N,str1,str2,str3,...)

Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().

{noformat}
mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
        -> 'ej'
mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
        -> 'foo'
{noformat}




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733012#action_12733012 ] 

Namit Jain commented on HIVE-512:
---------------------------------

I think we should follow the same convention as we do for CASE statement. The same denominator type should be returned

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732913#action_12732913 ] 

Min Zhou commented on HIVE-512:
-------------------------------

Originally, arguments after the first one of elt the can only be strings, but for more widely applicable,  automatic conversion is added. 
It's a string function, not a function on ints and other types besides strings. I think is very resonable return a string.  

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Work started: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on HIVE-512 started by Min Zhou.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732911#action_12732911 ] 

Min Zhou commented on HIVE-512:
-------------------------------

Here is the definition of elt:  Return string at index number. 
It's essentially a string function
select elt(1, 2, 3) will return a varbinary in mysql, rather than a int. I still insist returning string is better. 

Even if do it as you said,  what  type of results will  return when doing queries like below?

select(1, '2', 3)
select(2, '2', 3)
select(1, true, 3)
select(2, 2.0, cast(3 as double))



> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Min Zhou updated HIVE-512:
--------------------------

    Attachment: HIVE-512.2.patch

patch, tested all test cases.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Prasad Chakka (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732912#action_12732912 ] 

Prasad Chakka commented on HIVE-512:
------------------------------------

it may have been more useful to return a common denominator type but mysql behaves differently. varbinary in mysql seems to be more closer to a string than to a number. so if we want to follow mysql it is better to return number and let user cast it to int. it is weird though to return a string if all arguments are numeric.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733015#action_12733015 ] 

Min Zhou commented on HIVE-512:
-------------------------------

can you answer me about this queries?


> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Namit Jain resolved HIVE-512.
-----------------------------

      Resolution: Fixed
    Hadoop Flags: [Reviewed]

Committed. Thanks Min

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732612#action_12732612 ] 

Namit Jain commented on HIVE-512:
---------------------------------

mysql> create table t1 as select elt(1, 2, 3);
Query OK, 1 row affected (0.27 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> describe t1;
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| elt(1, 2, 3) | varbinary(1) | YES  |     | NULL    |       | 
+--------------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> create table t2 as select elt(1, 'a', 'b');
Query OK, 1 row affected (0.07 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> describe t2;
+------------------+------------+------+-----+---------+-------+
| Field            | Type       | Null | Key | Default | Extra |
+------------------+------------+------+-----+---------+-------+
| elt(1, 'a', 'b') | varchar(1) | YES  |     | NULL    |       | 
+------------------+------------+------+-----+---------+-------+
1 row in set (0.00 sec)



the return datatype of elt is the least common denominator of all the arguments, whereas it is always string in your case.
Can you change the function to return the least common denominator ?

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732829#action_12732829 ] 

Min Zhou commented on HIVE-512:
-------------------------------

some typo.
Based on the above, I think it better return string sine binary isnot commonly used in hive. 

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Min Zhou updated HIVE-512:
--------------------------

    Attachment: HIVE-512.patch

patch w/o unit test.  the api of GenericUDF leaded something inconvenient to custom an GenericUDF. 
I've commentted those inconvenience in my patch.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733082#action_12733082 ] 

Namit Jain commented on HIVE-512:
---------------------------------

As I said before, the return type should be the same as would be for case


select case x then '2' else 3 
select case x then '2' else 3
select case x then true else 3
select case x then 2.0 else cast(3 as double)

The first argument's value is not important as far as the return type is concerned

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732903#action_12732903 ] 

Namit Jain commented on HIVE-512:
---------------------------------

select elt(1,2,3) should return an int instead of string

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733016#action_12733016 ] 

Min Zhou commented on HIVE-512:
-------------------------------

select(1, '2', 3)
select(2, '2', 3)
select(1, true, 3)
select(2, 2.0, cast(3 as double))

if we don't uniformly return strings, it would be confused to user detemining which type will return.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Namit Jain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733246#action_12733246 ] 

Namit Jain commented on HIVE-512:
---------------------------------

OK

+1

I will commit it if the  tests pass

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732828#action_12732828 ] 

Min Zhou commented on HIVE-512:
-------------------------------

actually, elt return only two types of results in mysql : varbinary, varchar. 
varchar will be returned if all arguments are varchars, or varbinarys will be returned. 

mysql> create table t3 as select elt(1, 'a',  3);
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> describe t3;                   
+-----------------+--------------+------+-----+---------+-------+
| Field           | Type         | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| elt(1, 'a',  3) | varbinary(1) | YES  |     | NULL    |       |
+-----------------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> create table t4 as select elt(1, true,  false);     
Query OK, 1 row affected (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> describe t4;                  
+----------------------+--------------+------+-----+---------+-------+
| Field                | Type         | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+-------+
| elt(1, true,  false) | varbinary(1) | YES  |     | NULL    |       |
+----------------------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)


mysql> create table t5 as select elt(1, 2.0,  false);     
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> describe t5;                  
+---------------------+--------------+------+-----+---------+-------+
| Field               | Type         | Null | Key | Default | Extra |
+---------------------+--------------+------+-----+---------+-------+
| elt(1, 2.0,  false) | varbinary(4) | YES  |     | NULL    |       |
+---------------------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

	
Based on the above, I think it better return string as binary is commonly used  in hive. 


> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)

Posted by "Min Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733103#action_12733103 ] 

Min Zhou commented on HIVE-512:
-------------------------------

If you inspected the implementation of case, you will know it's unacceptable to case with different types of arguments.
see: GenericUDFCase.java , GenericUDFWhen.java 
{code}
hive> select case when true then '2' else 3 end from pokes limit 1;
FAILED: Error in semantic analysis: line 1:36 Argument Type Mismatch 3: The expression after ELSE should have the same type as those after THEN: "string" is expected but "int" is found
{code}

elt is a string function, confusion will be caused if we casually change its behavior. It no need make things more complex.

> [GenericUDF] new string function ELT(N,str1,str2,str3,...) 
> -----------------------------------------------------------
>
>                 Key: HIVE-512
>                 URL: https://issues.apache.org/jira/browse/HIVE-512
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Query Processor
>    Affects Versions: 0.4.0
>            Reporter: Min Zhou
>            Assignee: Min Zhou
>             Fix For: 0.4.0
>
>         Attachments: HIVE-512.2.patch, HIVE-512.patch
>
>
> ELT(N,str1,str2,str3,...)
> Returns str1 if N = 1, str2 if N = 2, and so on. Returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().
> {noformat}
> mysql> SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');
>         -> 'ej'
> mysql> SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');
>         -> 'foo'
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.