diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index 1a412a3a86..db14182baf 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -193,6 +193,7 @@ static { system.registerGenericUDF("concat", GenericUDFConcat.class); + system.registerUDF("mid", UDFSubstr.class, false); system.registerUDF("substr", UDFSubstr.class, false); system.registerUDF("substring", UDFSubstr.class, false); system.registerGenericUDF("substring_index", GenericUDFSubstringIndex.class); @@ -498,6 +499,7 @@ system.registerGenericUDF("in_file", GenericUDFInFile.class); system.registerGenericUDF("instr", GenericUDFInstr.class); system.registerGenericUDF("locate", GenericUDFLocate.class); + system.registerGenericUDF("position", GenericUDFLocate.class); system.registerGenericUDF("elt", GenericUDFElt.class); system.registerGenericUDF("concat_ws", GenericUDFConcatWS.class); system.registerGenericUDF("sort_array", GenericUDFSortArray.class); diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java index 4136cc7a79..5b1964c50a 100755 --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java @@ -33,7 +33,7 @@ * UDFSubstr. * */ -@Description(name = "substr,substring", +@Description(name = "substr,substring,mid", value = "_FUNC_(str, pos[, len]) - returns the substring of str that" + " starts at pos and is of length len or" + "_FUNC_(bin, pos[, len]) - returns the slice of byte array that" diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java index cebc7524e8..a0772228fc 100644 --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java @@ -42,7 +42,7 @@ * *

*/ -@Description(name = "locate", +@Description(name = "locate,position", value = "_FUNC_(substr, str[, pos]) - Returns the position of the first " + "occurance of substr in str after position pos", extended = "Example:\n" diff --git ql/src/test/results/clientpositive/show_functions.q.out ql/src/test/results/clientpositive/show_functions.q.out index 4942fddbe0..bbf730c8b4 100644 --- ql/src/test/results/clientpositive/show_functions.q.out +++ ql/src/test/results/clientpositive/show_functions.q.out @@ -167,6 +167,7 @@ mask_show_last_n matchpath max md5 +mid min minute mod @@ -195,6 +196,7 @@ percentile_approx pi pmod posexplode +position positive pow power @@ -436,6 +438,7 @@ mask_show_last_n matchpath max md5 +mid min minute mod diff --git ql/src/test/results/clientpositive/udf_locate.q.out ql/src/test/results/clientpositive/udf_locate.q.out index 63213b3b5e..cb3f63bd1b 100644 --- ql/src/test/results/clientpositive/udf_locate.q.out +++ ql/src/test/results/clientpositive/udf_locate.q.out @@ -8,6 +8,7 @@ PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION EXTENDED locate POSTHOOK: type: DESCFUNCTION locate(substr, str[, pos]) - Returns the position of the first occurance of substr in str after position pos +Synonyms: position Example: > SELECT locate('bar', 'foobarbar', 5) FROM src LIMIT 1; 7 diff --git ql/src/test/results/clientpositive/udf_substr.q.out ql/src/test/results/clientpositive/udf_substr.q.out index 4489006d9a..00fa6061e1 100644 --- ql/src/test/results/clientpositive/udf_substr.q.out +++ ql/src/test/results/clientpositive/udf_substr.q.out @@ -8,7 +8,7 @@ PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION EXTENDED substr POSTHOOK: type: DESCFUNCTION substr(str, pos[, len]) - returns the substring of str that starts at pos and is of length len orsubstr(bin, pos[, len]) - returns the slice of byte array that starts at pos and is of length len -Synonyms: substring +Synonyms: mid, substring pos is a 1-based index. If pos<0 the starting position is determined by counting backwards from the end of str. Example: > SELECT substr('Facebook', 5) FROM src LIMIT 1; diff --git ql/src/test/results/clientpositive/udf_substring.q.out ql/src/test/results/clientpositive/udf_substring.q.out index 72898e64a0..d6b1c4aa51 100644 --- ql/src/test/results/clientpositive/udf_substring.q.out +++ ql/src/test/results/clientpositive/udf_substring.q.out @@ -8,7 +8,7 @@ PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION EXTENDED substring POSTHOOK: type: DESCFUNCTION substring(str, pos[, len]) - returns the substring of str that starts at pos and is of length len orsubstring(bin, pos[, len]) - returns the slice of byte array that starts at pos and is of length len -Synonyms: substr +Synonyms: mid, substr pos is a 1-based index. If pos<0 the starting position is determined by counting backwards from the end of str. Example: > SELECT substring('Facebook', 5) FROM src LIMIT 1;