Skip to content

Commit

Permalink
add or revise function description
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshan committed Jul 27, 2016
1 parent 56821a2 commit 677b542
Show file tree
Hide file tree
Showing 35 changed files with 138 additions and 10 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ You can also directly download file from [release page](https://github.com/aaron

| function| description |
|:--|:--|
|array_contains(array, value) -> boolean | whether ARRAY contains value or not.|
|array_intersect(array, array) -> array | returns the two array's intersection, without duplicates..|
|array_contains(array<E>, E) -> boolean | whether array contains value or not.|
|array_intersect(array, array) -> array | returns the two array's intersection, without duplicates.|
|array_max(array<E>) -> E | returns the maximum value of input array.|
|array_min(array<E>) -> E | returns the minimum value of input array.|
|array_join(array, delimiter, null_replacement) -> string | concatenates the elements of the given array using the delimiter and an optional `null_replacement` to replace nulls.|
|array_distinct(array) -> array | remove duplicate values from the array.|
|array_position(array, value) -> long | returns the position of the first occurrence of the element in array (or 0 if not found).|
|array_remove(array, value) -> array | remove all elements that equal element from array.|
|array_position(array<E>, E) -> long | returns the position of the first occurrence of the element in array (or 0 if not found).|
|array_remove(array<E>, E) -> array | remove all elements that equal element from array.|
|array_reverse(array) -> array | reverse the array element.|
|array_sort(array) -> array | sorts and returns the array x. The elements of x must be orderable..|
|array_sort(array) -> array | sorts and returns the array. The elements of array must be orderable.|
|array_concat(array, array) -> array | concatenates two arrays.|
|array_value_count(array, value) -> long | count ARRAY's element number that element value equals given value.|
|array_slice(array, start, length) -> array | subsets array starting from index start (or starting from the end if start is negative) with a length of length|
|array_value_count(array<E>, E) -> long | count array's element number that element value equals given value.|
|array_slice(array, start, length) -> array | subsets array starting from index start (or starting from the end if start is negative) with a length of length.|
|array_element_at(array<E>, index) -> E | returns element of array at given index. If index < 0, element_at accesses elements from the last to the first.|

### 3. date functions
Expand All @@ -79,7 +79,7 @@ You can also directly download file from [release page](https://github.com/aaron
| function| description |
|:--|:--|
|json_array_get(json, jsonPath) -> array(varchar) |returns the element at the specified index into the `json_array`. The index is zero-based.|
|json_array_length(json, jsonPath) -> array(varchar) |Returns the array length of `json` (a string containing a JSON array).|
|json_array_length(json, jsonPath) -> array(varchar) |returns the array length of `json` (a string containing a JSON array).|
|json_array_extract(json, jsonPath) -> array(varchar) |extract json array by given jsonPath.|
|json_array_extract_scalar(json, jsonPath) -> array(varchar) |like `json_array_extract`, but returns the result value as a string (as opposed to being encoded as JSON).|
|json_extract(json, jsonPath) -> array(varchar) |extract json by given jsonPath.|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -13,6 +14,9 @@
* @date 2016-07-26
* @time 17:30
*/
@Description(name = "array_concat"
, value = "_FUNC_(array, array) - concatenates two arrays."
, extended = "Example:\n > select _FUNC_(array, array) from src;")
public class UDFArrayConcat extends GenericUDF {
private static final int ARG_COUNT = 2; // Number of arguments to this UDF
private transient ListObjectInspector leftArrayOI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.shanruifeng.functions.array;

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -15,6 +16,9 @@
* @author ruifeng.shan
* @date 2015-3-23
*/
@Description(name = "array_contains"
, value = "_FUNC_(array<E>, E) - whether array contains value or not."
, extended = "Example:\n > select _FUNC_(array, value) from src;")
public class UDFArrayContains extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.unimi.dsi.fastutil.ints.IntArrays;
import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-26
* @time 17:29
*/
@Description(name = "array_distinct"
, value = "_FUNC_(array) - remove duplicate values from the array."
, extended = "Example:\n > select _FUNC_(array) from src;")
public class UDFArrayDistinct extends GenericUDF {
private static final int INITIAL_SIZE = 128;
private static final int ARG_COUNT = 1; // Number of arguments to this UDF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.shanruifeng.functions.array;

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-27
* @time 10:09
*/
@Description(name = "array_element_at"
, value = "_FUNC_(array<E>, index) - returns element of array at given index. If index < 0, element_at accesses elements from the last to the first."
, extended = "Example:\n > select _FUNC_(array, index) from src;")
public class UDFArrayElementAt extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.unimi.dsi.fastutil.ints.IntArrays;
import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -17,6 +18,9 @@
* @date 2016-07-26
* @time 11:57
*/
@Description(name = "array_intersect"
, value = "_FUNC_(array, array) - returns the two array's intersection, without duplicates."
, extended = "Example:\n > select _FUNC_(array, array) from src;")
public class UDFArrayIntersect extends GenericUDF {
private static final int INITIAL_SIZE = 128;
private static final int ARG_COUNT = 2; // Number of arguments to this UDF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.shanruifeng.functions.array;

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -17,6 +18,9 @@
* @date 2016-07-26
* @time 17:31
*/
@Description(name = "array_join"
, value = "_FUNC_(array<E>, delimiter, null_replacement) - concatenates the elements of the given array using the delimiter and an optional null_replacement to replace nulls."
, extended = "Example:\n > select _FUNC_(array, delimiter) from src;\n> select _FUNC_(array, delimiter, null_replacement) from src;")
public class UDFArrayJoin extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cc/shanruifeng/functions/array/UDFArrayMax.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import it.unimi.dsi.fastutil.ints.IntArrays;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -17,6 +18,9 @@
* @date 2016-07-26
* @time 17:31
*/
@Description(name = "array_max"
, value = "_FUNC_(array) - returns the maximum value of input array."
, extended = "Example:\n > select _FUNC_(array) from src;")
public class UDFArrayMax extends GenericUDF {
private static final int INITIAL_SIZE = 128;
private static final int ARG_COUNT = 1; // Number of arguments to this UDF
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/cc/shanruifeng/functions/array/UDFArrayMin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import it.unimi.dsi.fastutil.ints.IntArrays;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -17,6 +18,9 @@
* @date 2016-07-26
* @time 17:32
*/
@Description(name = "array_min"
, value = "_FUNC_(array) - returns the minimum value of input array."
, extended = "Example:\n > select _FUNC_(array) from src;")
public class UDFArrayMin extends GenericUDF {
private static final int INITIAL_SIZE = 128;
private static final int ARG_COUNT = 1; // Number of arguments to this UDF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.shanruifeng.functions.array;

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-26
* @time 17:32
*/
@Description(name = "array_position"
, value = "_FUNC_(array<E>, E) - returns the position of the first occurrence of the element in array (or 0 if not found)."
, extended = "Example:\n > select _FUNC_(array, value) from src;")
public class UDFArrayPosition extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-26
* @time 18:07
*/
@Description(name = "array_remove"
, value = "_FUNC_(array<E>, E) - remove all elements that equal element from array."
, extended = "Example:\n > select _FUNC_(array, value) from src;")
public class UDFArrayRemove extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -13,6 +14,9 @@
* @date 2016-07-26
* @time 18:03
*/
@Description(name = "array_reverse"
, value = "_FUNC_(array) - reverse the array element."
, extended = "Example:\n > select _FUNC_(array) from src;")
public class UDFArrayReverse extends GenericUDF {
private static final int ARG_COUNT = 1; // Number of arguments to this UDF
private transient ListObjectInspector arrayOI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.array;

import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -18,6 +19,9 @@
* @date 2016-07-27
* @time 10:24
*/
@Description(name = "array_slice"
, value = "_FUNC_(array<E>, start, length) - subsets array starting from index start (or starting from the end if start is negative) with a length of length."
, extended = "Example:\n > select _FUNC_(array, start, length) from src;")
public class UDFArraySlice extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.unimi.dsi.fastutil.ints.IntArrays;
import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-26
* @time 17:32
*/
@Description(name = "array_sort"
, value = "_FUNC_(array) - sorts and returns the array. The elements of array must be orderable."
, extended = "Example:\n > select _FUNC_(array) from src;")
public class UDFArraySort extends GenericUDF {
private static final int INITIAL_SIZE = 128;
private static final int ARG_COUNT = 1; // Number of arguments to this UDF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.shanruifeng.functions.array;

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
Expand All @@ -16,6 +17,9 @@
* @date 2016-07-26
* @time 20:58
*/
@Description(name = "array_value_count"
, value = "_FUNC_(array<E>, E) - count array's element number that element value equals given value."
, extended = "Example:\n > select _FUNC_(array, value) from src;")
public class UDFArrayValueCount extends GenericUDF {

private static final int ARRAY_IDX = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
* @date 2016-07-25
* @time 20:12
*/
@Description(name = "id_card_area"
, value = "_FUNC_(string) - get area by given china id card."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardArea extends UDF {
private Text result = new Text();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
* @date 2016-07-25
* @time 20:14
*/
@Description(name = "id_card_birthday"
, value = "_FUNC_(string) - get birthday by given china id card."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardBirthday extends UDF{
private Text result = new Text();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
* @date 2016-07-25
* @time 20:11
*/
@Description(name = "id_card_city"
, value = "_FUNC_(string) - get city by given china id card."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardCity extends UDF {
private Text result = new Text();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
* @date 2016-07-25
* @time 20:14
*/
@Description(name = "id_card_gender"
, value = "_FUNC_(string) - get gender by given china id card."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardGender extends UDF {
private Text result = new Text();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
*/

//身份证->json
@Description(name = "id_card_info"
, value = "_FUNC_(string) - get all info by given china id card, output is json string."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardInfo extends UDF {
private Text result = new Text();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.shanruifeng.functions.card;

import cc.shanruifeng.functions.utils.CardUtils;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

Expand All @@ -9,6 +10,9 @@
* @date 2016-07-25
* @time 19:42
*/
@Description(name = "id_card_province"
, value = "_FUNC_(string) - get province by given china id card."
, extended = "Example:\n > select _FUNC_(string) from src;")
public class UDFChinaIdCardProvince extends UDF {
private Text result = new Text();

Expand Down
Loading

0 comments on commit 677b542

Please sign in to comment.