hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Namit Jain (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HIVE-512) [GenericUDF] new string function ELT(N,str1,str2,str3,...)
Date Fri, 17 Jul 2009 17:07:14 GMT

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


Mime
View raw message