hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alejandro Fernandez <afernan...@hortonworks.com>
Subject Re: Review Request 43706: HIVE-13063 Create UDFs for CHAR and REPLACE
Date Wed, 02 Mar 2016 06:19:13 GMT

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

(Updated March 2, 2016, 6:19 a.m.)


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


Changes
-------

Updated unit tests. Hopefully for the last time.


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 (updated)
-----

  ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java d1e1441 
  ql/src/java/org/apache/hadoop/hive/ql/udf/UDFChr.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/TestGenericUDFChr.java PRE-CREATION 
  ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFReplace.java PRE-CREATION

  ql/src/test/queries/clientpositive/udf_chr.q PRE-CREATION 
  ql/src/test/queries/clientpositive/udf_replace.q PRE-CREATION 
  ql/src/test/results/clientpositive/show_functions.q.out 789bedf 
  ql/src/test/results/clientpositive/udf_chr.q.out PRE-CREATION 
  ql/src/test/results/clientpositive/udf_replace.q.out 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');


File Attachments
----------------

Query1
  https://reviews.apache.org/media/uploaded/files/2016/02/18/6f9c8b55-3e75-448f-bd71-93d6c3c900b8__Screen_Shot_2016-02-17_at_7.21.07_PM.png
Query2
  https://reviews.apache.org/media/uploaded/files/2016/02/18/cedeeec0-388b-433b-a4f6-94888054d1a9__Screen_Shot_2016-02-17_at_7.20.57_PM.png


Thanks,

Alejandro Fernandez


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