[ 
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.

Reply via email to