hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alejandro Fernandez <afernan...@hortonworks.com>
Subject Review Request 43706: HIVE-13063 Create UDFs for CHAR and REPLACE
Date Thu, 18 Feb 2016 03:36:21 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/43706/
-----------------------------------------------------------

Review request for hive, Jason Dere and Vikram Dixit Kumaraswamy.


Bugs: HIVE-13063
    https://issues.apache.org/jira/browse/HIVE-13063


Repository: hive-git


Description
-------

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'"


Diffs
-----

  ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java e0e030f 
  ql/src/java/org/apache/hadoop/hive/ql/udf/UDFChar.java PRE-CREATION 
  ql/src/java/org/apache/hadoop/hive/ql/udf/UDFReplace.java PRE-CREATION 
  ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFChar.java PRE-CREATION 
  ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFReplace.java PRE-CREATION


Diff: https://reviews.apache.org/r/43706/diff/


Testing
-------

Verified that UDFs work.

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


Thanks,

Alejandro Fernandez


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message