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

Alejandro Fernandez commented on HIVE-13063:
--------------------------------------------

Verified it worked with,

{code}
ADD JAR hdfs://c6401.ambari.apache.org:8020/tmp/hive-exec.jar;
CREATE TEMPORARY FUNCTION char_udf AS 'org.apache.hadoop.hive.ql.udf.UDFChar';
CREATE TEMPORARY FUNCTION replace_udf AS 
'org.apache.hadoop.hive.ql.udf.UDFReplace';

SHOW FUNCTIONS;

DESCRIBE FUNCTION char_udf;
DESCRIBE FUNCTION replace_udf;

select char_udf(-1), 
char_udf(0), 
char_udf(1), 
char_udf(48), 
char_udf(65), 
char_udf(68.12), 
char_udf(32457964);

select replace_udf('', '', ''), 
replace_udf(null, '', ''), 
replace_udf('', null, ''), 
replace_udf('', '', null), 
replace_udf('Hack and Hue', 'H', 'BL'), 
replace_udf('ABABrdvABrk', 'AB', 'a');
{code}

> Create UDFs for CHAR and REPLACE 
> ---------------------------------
>
>                 Key: HIVE-13063
>                 URL: https://issues.apache.org/jira/browse/HIVE-13063
>             Project: Hive
>          Issue Type: Improvement
>          Components: HiveServer2
>    Affects Versions: 1.2.0
>            Reporter: Alejandro Fernandez
>            Assignee: Alejandro Fernandez
>             Fix For: 2.1.0
>
>         Attachments: HIVE-13063.patch, Screen Shot 2016-02-17 at 7.20.57 
> PM.png, Screen Shot 2016-02-17 at 7.21.07 PM.png
>
>
> Create UDFS for these functions.
> CHAR: convert n where n : [0, 256) into the ascii equivalent as a varchar. If 
> n is less than 0 or greater than 255, return the empty string. If n is 0, 
> return null.
> REPLACE: replace all substrings of 'str' that match 'search' with 'rep'.
> Example. SELECT REPLACE('Hack and Hue', 'H', 'BL');
> Equals 'BLack and BLue'"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to