HIVE-15975 : Support the MOD function (Teddy Choi via Ashutosh Chauhan) Signed-off-by: Ashutosh Chauhan <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ea0bc430 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ea0bc430 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ea0bc430 Branch: refs/heads/hive-14535 Commit: ea0bc430c690f5084a67ef391be4e6ac478aacde Parents: 0a5ea20 Author: Author: Teddy Choi <[email protected]> Authored: Sat Feb 25 20:22:00 2017 -0800 Committer: Ashutosh Chauhan <[email protected]> Committed: Thu Mar 9 08:42:37 2017 -0800 ---------------------------------------------------------------------- .../hadoop/hive/ql/exec/FunctionRegistry.java | 1 + ql/src/test/queries/clientpositive/udf_modulo.q | 7 ++++++ .../results/clientpositive/show_functions.q.out | 2 ++ .../results/clientpositive/udf_modulo.q.out | 23 ++++++++++++++++++++ 4 files changed, 33 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/ea0bc430/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index aaf2399..4ac25c2 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -333,6 +333,7 @@ public final class FunctionRegistry { system.registerGenericUDF("*", GenericUDFOPMultiply.class); system.registerGenericUDF("/", GenericUDFOPDivide.class); system.registerGenericUDF("%", GenericUDFOPMod.class); + system.registerGenericUDF("mod", GenericUDFOPMod.class); system.registerUDF("div", UDFOPLongDivide.class, true); system.registerUDF("&", UDFOPBitAnd.class, true); http://git-wip-us.apache.org/repos/asf/hive/blob/ea0bc430/ql/src/test/queries/clientpositive/udf_modulo.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/udf_modulo.q b/ql/src/test/queries/clientpositive/udf_modulo.q index 70f511f..28a9b10 100644 --- a/ql/src/test/queries/clientpositive/udf_modulo.q +++ b/ql/src/test/queries/clientpositive/udf_modulo.q @@ -1,2 +1,9 @@ +set hive.fetch.task.conversion=more; + +DESCRIBE FUNCTION mod; +DESCRIBE FUNCTION EXTENDED mod; + +SELECT mod(3, 2) FROM SRC tablesample (1 rows); + DESCRIBE FUNCTION %; DESCRIBE FUNCTION EXTENDED %; http://git-wip-us.apache.org/repos/asf/hive/blob/ea0bc430/ql/src/test/results/clientpositive/show_functions.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/show_functions.q.out b/ql/src/test/results/clientpositive/show_functions.q.out index 3c9bb4a..1361b93 100644 --- a/ql/src/test/results/clientpositive/show_functions.q.out +++ b/ql/src/test/results/clientpositive/show_functions.q.out @@ -154,6 +154,7 @@ max md5 min minute +mod month months_between named_struct @@ -382,6 +383,7 @@ max md5 min minute +mod month months_between xpath http://git-wip-us.apache.org/repos/asf/hive/blob/ea0bc430/ql/src/test/results/clientpositive/udf_modulo.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/udf_modulo.q.out b/ql/src/test/results/clientpositive/udf_modulo.q.out index 084dc45..b093625 100644 --- a/ql/src/test/results/clientpositive/udf_modulo.q.out +++ b/ql/src/test/results/clientpositive/udf_modulo.q.out @@ -1,3 +1,25 @@ +PREHOOK: query: DESCRIBE FUNCTION mod +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION mod +POSTHOOK: type: DESCFUNCTION +a mod b - Returns the remainder when dividing a by b +PREHOOK: query: DESCRIBE FUNCTION EXTENDED mod +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION EXTENDED mod +POSTHOOK: type: DESCFUNCTION +a mod b - Returns the remainder when dividing a by b +Synonyms: % +Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPMod +Function type:BUILTIN +PREHOOK: query: SELECT mod(3, 2) FROM SRC tablesample (1 rows) +PREHOOK: type: QUERY +PREHOOK: Input: default@src +#### A masked pattern was here #### +POSTHOOK: query: SELECT mod(3, 2) FROM SRC tablesample (1 rows) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +#### A masked pattern was here #### +1 PREHOOK: query: DESCRIBE FUNCTION % PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION % @@ -8,5 +30,6 @@ PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION EXTENDED % POSTHOOK: type: DESCFUNCTION a % b - Returns the remainder when dividing a by b +Synonyms: mod Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPMod Function type:BUILTIN
