You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Alejandro Fernandez <af...@hortonworks.com> on 2016/03/02 07:19:13 UTC

Re: Review Request 43706: HIVE-13063 Create UDFs for CHAR and REPLACE

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


Re: Review Request 43706: HIVE-13063 Create UDFs for CHAR and REPLACE

Posted by Alejandro Fernandez <af...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/43706/
-----------------------------------------------------------

(Updated March 4, 2016, 7:25 a.m.)


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


Changes
-------

Last patch after changing char(0) to nul character


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