hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jd...@apache.org
Subject svn commit: r1669390 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/exec/ java/org/apache/hadoop/hive/ql/udf/ test/queries/clientpositive/ test/results/clientpositive/
Date Thu, 26 Mar 2015 18:06:59 GMT
Author: jdere
Date: Thu Mar 26 18:06:58 2015
New Revision: 1669390

URL: http://svn.apache.org/r1669390
Log:
HIVE-9859: Create bitwise left/right shift UDFs (Alexander Pivovarov via Jason Dere)

Added:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftLeft.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRight.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRightUnsigned.java
    hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftleft.q
    hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftright.q
    hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftrightunsigned.q
    hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftleft.q.out
    hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftright.q.out
    hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftrightunsigned.q.out
Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
    hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java?rev=1669390&r1=1669389&r2=1669390&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java Thu Mar 26
18:06:58 2015
@@ -68,8 +68,11 @@ import org.apache.hadoop.hive.ql.udf.UDF
 import org.apache.hadoop.hive.ql.udf.UDFMinute;
 import org.apache.hadoop.hive.ql.udf.UDFMonth;
 import org.apache.hadoop.hive.ql.udf.UDFOPBitAnd;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftLeft;
 import org.apache.hadoop.hive.ql.udf.UDFOPBitNot;
 import org.apache.hadoop.hive.ql.udf.UDFOPBitOr;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftRight;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftRightUnsigned;
 import org.apache.hadoop.hive.ql.udf.UDFOPBitXor;
 import org.apache.hadoop.hive.ql.udf.UDFOPLongDivide;
 import org.apache.hadoop.hive.ql.udf.UDFPI;
@@ -294,6 +297,9 @@ public final class FunctionRegistry {
     system.registerUDF("|", UDFOPBitOr.class, true);
     system.registerUDF("^", UDFOPBitXor.class, true);
     system.registerUDF("~", UDFOPBitNot.class, true);
+    system.registerUDF("shiftleft", UDFOPBitShiftLeft.class, true);
+    system.registerUDF("shiftright", UDFOPBitShiftRight.class, true);
+    system.registerUDF("shiftrightunsigned", UDFOPBitShiftRightUnsigned.class, true);
 
     system.registerGenericUDF("current_database", UDFCurrentDB.class);
     system.registerGenericUDF("current_date", GenericUDFCurrentDate.class);

Added: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftLeft.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftLeft.java?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftLeft.java (added)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftLeft.java Thu Mar 26
18:06:58 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+
+/**
+ * UDFOPBitLeftShift.
+ *
+ */
+@Description(name = "shiftleft", value = "_FUNC_(a, b) - Bitwise left shift",
+    extended = "Returns int for tinyint, smallint and int a. Returns bigint for bigint a."
+    + "\nExample:\n  > SELECT _FUNC_(2, 1);\n  4")
+public class UDFOPBitShiftLeft extends UDFBaseBitOP {
+
+  public UDFOPBitShiftLeft() {
+  }
+
+  public IntWritable evaluate(ByteWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() << b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(ShortWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() << b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(IntWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() << b.get());
+    return intWritable;
+  }
+
+  public LongWritable evaluate(LongWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    longWritable.set(a.get() << b.get());
+    return longWritable;
+  }
+}

Added: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRight.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRight.java?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRight.java (added)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRight.java Thu Mar 26
18:06:58 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+
+/**
+ * UDFOPBitRightShift.
+ *
+ */
+@Description(name = "shiftright", value = "_FUNC_(a, b) - Bitwise right shift",
+    extended = "Returns int for tinyint, smallint and int a. Returns bigint for bigint a."
+    + "\nExample:\n  > SELECT _FUNC_(4, 1);\n  2")
+public class UDFOPBitShiftRight extends UDFBaseBitOP {
+
+  public UDFOPBitShiftRight() {
+  }
+
+  public IntWritable evaluate(ByteWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >> b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(ShortWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >> b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(IntWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >> b.get());
+    return intWritable;
+  }
+
+  public LongWritable evaluate(LongWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    longWritable.set(a.get() >> b.get());
+    return longWritable;
+  }
+}

Added: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRightUnsigned.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRightUnsigned.java?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRightUnsigned.java (added)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitShiftRightUnsigned.java Thu
Mar 26 18:06:58 2015
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+
+/**
+ * UDFOPBitUnsignedRightShift.
+ *
+ */
+@Description(name = "shiftrightunsigned", value = "_FUNC_(a, b) - Bitwise unsigned right
shift",
+    extended = "Returns int for tinyint, smallint and int a. Returns bigint for bigint a."
+    + "\nExample:\n  > SELECT _FUNC_(4, 1);\n  2")
+public class UDFOPBitShiftRightUnsigned extends UDFBaseBitOP {
+
+  public UDFOPBitShiftRightUnsigned() {
+  }
+
+  public IntWritable evaluate(ByteWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >>> b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(ShortWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >>> b.get());
+    return intWritable;
+  }
+
+  public IntWritable evaluate(IntWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    intWritable.set(a.get() >>> b.get());
+    return intWritable;
+  }
+
+  public LongWritable evaluate(LongWritable a, IntWritable b) {
+    if (a == null || b == null) {
+      return null;
+    }
+    longWritable.set(a.get() >>> b.get());
+    return longWritable;
+  }
+}

Added: hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftleft.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftleft.q?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftleft.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftleft.q Thu Mar 26 18:06:58
2015
@@ -0,0 +1,93 @@
+DESCRIBE FUNCTION shiftleft;
+DESC FUNCTION EXTENDED shiftleft;
+
+explain select shiftleft(4, 1);
+
+select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as tinyint) a
+) t;
+
+select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as smallint) a
+) t;
+
+select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as int) a
+) t;
+
+select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as bigint) a
+) t;
+
+select
+shiftleft(4, 33),
+shiftleft(4, 65),
+shiftleft(4, 4001),
+shiftleft(16, -2),
+shiftleft(4, cast(null as int)),
+shiftleft(cast(null as int), 4),
+shiftleft(cast(null as int), cast(null as int));
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftright.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftright.q?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftright.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftright.q Thu Mar 26 18:06:58
2015
@@ -0,0 +1,78 @@
+DESCRIBE FUNCTION shiftright;
+DESC FUNCTION EXTENDED shiftright;
+
+explain select shiftright(4, 1);
+
+select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 3),
+shiftright(a, 4),
+shiftright(a, 5),
+shiftright(a, 6),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t;
+
+select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 8),
+shiftright(a, 9),
+shiftright(a, 10),
+shiftright(a, 11),
+shiftright(a, 12),
+shiftright(a, 13),
+shiftright(a, 14),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t;
+
+select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 24),
+shiftright(a, 25),
+shiftright(a, 26),
+shiftright(a, 27),
+shiftright(a, 28),
+shiftright(a, 29),
+shiftright(a, 30),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t;
+
+select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 56),
+shiftright(a, 57),
+shiftright(a, 58),
+shiftright(a, 59),
+shiftright(a, 60),
+shiftright(a, 61),
+shiftright(a, 62),
+shiftright(a, 63),
+shiftright(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t;
+
+select
+shiftright(1024, 33),
+shiftright(1024, 65),
+shiftright(1024, 4001),
+shiftright(1024, -2),
+shiftright(1024, cast(null as int)),
+shiftright(cast(null as int), 4),
+shiftright(cast(null as int), cast(null as int));
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftrightunsigned.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftrightunsigned.q?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftrightunsigned.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/udf_bitwise_shiftrightunsigned.q Thu Mar
26 18:06:58 2015
@@ -0,0 +1,53 @@
+DESCRIBE FUNCTION shiftrightunsigned;
+DESC FUNCTION EXTENDED shiftrightunsigned;
+
+explain select shiftrightunsigned(4, 1);
+
+select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t;
+
+select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t;
+
+select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t;
+
+select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 63),
+shiftrightunsigned(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t;
+
+select
+shiftrightunsigned(1024, 33),
+shiftrightunsigned(1024, 65),
+shiftrightunsigned(1024, 4001),
+shiftrightunsigned(1024, -2),
+shiftrightunsigned(1024, cast(null as int)),
+shiftrightunsigned(cast(null as int), 4),
+shiftrightunsigned(cast(null as int), cast(null as int));
\ No newline at end of file

Modified: hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out?rev=1669390&r1=1669389&r2=1669390&view=diff
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out (original)
+++ hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out Thu Mar 26 18:06:58
2015
@@ -166,6 +166,9 @@ rpad
 rtrim
 second
 sentences
+shiftleft
+shiftright
+shiftrightunsigned
 sign
 sin
 size

Added: hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftleft.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftleft.q.out?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftleft.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftleft.q.out Thu Mar 26 18:06:58
2015
@@ -0,0 +1,239 @@
+PREHOOK: query: DESCRIBE FUNCTION shiftleft
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION shiftleft
+POSTHOOK: type: DESCFUNCTION
+shiftleft(a, b) - Bitwise left shift
+PREHOOK: query: DESC FUNCTION EXTENDED shiftleft
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESC FUNCTION EXTENDED shiftleft
+POSTHOOK: type: DESCFUNCTION
+shiftleft(a, b) - Bitwise left shift
+Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
+Example:
+  > SELECT shiftleft(2, 1);
+  4
+PREHOOK: query: explain select shiftleft(4, 1)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select shiftleft(4, 1)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        TableScan
+          alias: _dummy_table
+          Row Limit Per Split: 1
+          Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+          Select Operator
+            expressions: 8 (type: int)
+            outputColumnNames: _col0
+            Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+            ListSink
+
+PREHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as tinyint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as tinyint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+4	8	16	32	64	128	256	512	1024	32768	65536	-2147483648	0	-2147483648	0
+PREHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as smallint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as smallint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+4	8	16	32	64	128	256	512	1024	32768	65536	-2147483648	0	-2147483648	0
+PREHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as int) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as int) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+4	8	16	32	64	128	256	512	1024	32768	65536	-2147483648	0	-2147483648	0
+PREHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as bigint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftleft(a, 0),
+shiftleft(a, 1),
+shiftleft(a, 2),
+shiftleft(a, 3),
+shiftleft(a, 4),
+shiftleft(a, 5),
+shiftleft(a, 6),
+shiftleft(a, 7),
+shiftleft(a, 8),
+shiftleft(a, 13),
+shiftleft(a, 14),
+shiftleft(a, 29),
+shiftleft(a, 30),
+shiftleft(a, 61),
+shiftleft(a, 62)
+from (
+  select cast(4 as bigint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+4	8	16	32	64	128	256	512	1024	32768	65536	2147483648	4294967296	-9223372036854775808	0
+PREHOOK: query: select
+shiftleft(4, 33),
+shiftleft(4, 65),
+shiftleft(4, 4001),
+shiftleft(16, -2),
+shiftleft(4, cast(null as int)),
+shiftleft(cast(null as int), 4),
+shiftleft(cast(null as int), cast(null as int))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftleft(4, 33),
+shiftleft(4, 65),
+shiftleft(4, 4001),
+shiftleft(16, -2),
+shiftleft(4, cast(null as int)),
+shiftleft(cast(null as int), 4),
+shiftleft(cast(null as int), cast(null as int))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+8	8	8	0	NULL	NULL	NULL

Added: hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftright.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftright.q.out?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftright.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftright.q.out Thu Mar 26
18:06:58 2015
@@ -0,0 +1,209 @@
+PREHOOK: query: DESCRIBE FUNCTION shiftright
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION shiftright
+POSTHOOK: type: DESCFUNCTION
+shiftright(a, b) - Bitwise right shift
+PREHOOK: query: DESC FUNCTION EXTENDED shiftright
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESC FUNCTION EXTENDED shiftright
+POSTHOOK: type: DESCFUNCTION
+shiftright(a, b) - Bitwise right shift
+Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
+Example:
+  > SELECT shiftright(4, 1);
+  2
+PREHOOK: query: explain select shiftright(4, 1)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select shiftright(4, 1)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        TableScan
+          alias: _dummy_table
+          Row Limit Per Split: 1
+          Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+          Select Operator
+            expressions: 2 (type: int)
+            outputColumnNames: _col0
+            Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+            ListSink
+
+PREHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 3),
+shiftright(a, 4),
+shiftright(a, 5),
+shiftright(a, 6),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 3),
+shiftright(a, 4),
+shiftright(a, 5),
+shiftright(a, 6),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-128	-64	-32	-16	-8	-4	-2	-1	-128
+PREHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 8),
+shiftright(a, 9),
+shiftright(a, 10),
+shiftright(a, 11),
+shiftright(a, 12),
+shiftright(a, 13),
+shiftright(a, 14),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 8),
+shiftright(a, 9),
+shiftright(a, 10),
+shiftright(a, 11),
+shiftright(a, 12),
+shiftright(a, 13),
+shiftright(a, 14),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-32768	-16384	-8192	-128	-64	-32	-16	-8	-4	-2	-1	-32768
+PREHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 24),
+shiftright(a, 25),
+shiftright(a, 26),
+shiftright(a, 27),
+shiftright(a, 28),
+shiftright(a, 29),
+shiftright(a, 30),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 24),
+shiftright(a, 25),
+shiftright(a, 26),
+shiftright(a, 27),
+shiftright(a, 28),
+shiftright(a, 29),
+shiftright(a, 30),
+shiftright(a, 31),
+shiftright(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-2147483648	-1073741824	-536870912	-128	-64	-32	-16	-8	-4	-2	-1	-2147483648
+PREHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 56),
+shiftright(a, 57),
+shiftright(a, 58),
+shiftright(a, 59),
+shiftright(a, 60),
+shiftright(a, 61),
+shiftright(a, 62),
+shiftright(a, 63),
+shiftright(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftright(a, 0),
+shiftright(a, 1),
+shiftright(a, 2),
+shiftright(a, 56),
+shiftright(a, 57),
+shiftright(a, 58),
+shiftright(a, 59),
+shiftright(a, 60),
+shiftright(a, 61),
+shiftright(a, 62),
+shiftright(a, 63),
+shiftright(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-9223372036854775808	-4611686018427387904	-2305843009213693952	-128	-64	-32	-16	-8	-4	-2
-1	-9223372036854775808
+PREHOOK: query: select
+shiftright(1024, 33),
+shiftright(1024, 65),
+shiftright(1024, 4001),
+shiftright(1024, -2),
+shiftright(1024, cast(null as int)),
+shiftright(cast(null as int), 4),
+shiftright(cast(null as int), cast(null as int))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftright(1024, 33),
+shiftright(1024, 65),
+shiftright(1024, 4001),
+shiftright(1024, -2),
+shiftright(1024, cast(null as int)),
+shiftright(cast(null as int), 4),
+shiftright(cast(null as int), cast(null as int))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+512	512	512	0	NULL	NULL	NULL

Added: hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftrightunsigned.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftrightunsigned.q.out?rev=1669390&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftrightunsigned.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/udf_bitwise_shiftrightunsigned.q.out Thu
Mar 26 18:06:58 2015
@@ -0,0 +1,159 @@
+PREHOOK: query: DESCRIBE FUNCTION shiftrightunsigned
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION shiftrightunsigned
+POSTHOOK: type: DESCFUNCTION
+shiftrightunsigned(a, b) - Bitwise unsigned right shift
+PREHOOK: query: DESC FUNCTION EXTENDED shiftrightunsigned
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESC FUNCTION EXTENDED shiftrightunsigned
+POSTHOOK: type: DESCFUNCTION
+shiftrightunsigned(a, b) - Bitwise unsigned right shift
+Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
+Example:
+  > SELECT shiftrightunsigned(4, 1);
+  2
+PREHOOK: query: explain select shiftrightunsigned(4, 1)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select shiftrightunsigned(4, 1)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        TableScan
+          alias: _dummy_table
+          Row Limit Per Split: 1
+          Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+          Select Operator
+            expressions: 2 (type: int)
+            outputColumnNames: _col0
+            Statistics: Num rows: 0 Data size: 1 Basic stats: PARTIAL Column stats: COMPLETE
+            ListSink
+
+PREHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-128 as tinyint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-128	2147483584	1073741792	1	-128
+PREHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-32768 as smallint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-32768	2147467264	1073733632	1	-32768
+PREHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 31),
+shiftrightunsigned(a, 32)
+from (
+  select cast(-2147483648 as int) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-2147483648	1073741824	536870912	1	-2147483648
+PREHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 63),
+shiftrightunsigned(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftrightunsigned(a, 0),
+shiftrightunsigned(a, 1),
+shiftrightunsigned(a, 2),
+shiftrightunsigned(a, 63),
+shiftrightunsigned(a, 64)
+from (
+  select cast(-9223372036854775808 as bigint) a
+) t
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+-9223372036854775808	4611686018427387904	2305843009213693952	1	-9223372036854775808
+PREHOOK: query: select
+shiftrightunsigned(1024, 33),
+shiftrightunsigned(1024, 65),
+shiftrightunsigned(1024, 4001),
+shiftrightunsigned(1024, -2),
+shiftrightunsigned(1024, cast(null as int)),
+shiftrightunsigned(cast(null as int), 4),
+shiftrightunsigned(cast(null as int), cast(null as int))
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+shiftrightunsigned(1024, 33),
+shiftrightunsigned(1024, 65),
+shiftrightunsigned(1024, 4001),
+shiftrightunsigned(1024, -2),
+shiftrightunsigned(1024, cast(null as int)),
+shiftrightunsigned(cast(null as int), 4),
+shiftrightunsigned(cast(null as int), cast(null as int))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+512	512	512	0	NULL	NULL	NULL



Mime
View raw message