You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2012/06/07 16:55:50 UTC
svn commit: r1347654 - in /hive/trunk: ql/src/test/queries/clientpositive/
ql/src/test/results/clientpositive/
serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/
Author: hashutosh
Date: Thu Jun 7 14:55:49 2012
New Revision: 1347654
URL: http://svn.apache.org/viewvc?rev=1347654&view=rev
Log:
HIVE-2736 : Hive UDFs cannot emit binary constants (Philip Tromans via Ashutosh Chauhan)
Added:
hive/trunk/ql/src/test/queries/clientpositive/binary_constant.q
hive/trunk/ql/src/test/results/clientpositive/binary_constant.q.out
hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
Modified:
hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
Added: hive/trunk/ql/src/test/queries/clientpositive/binary_constant.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/binary_constant.q?rev=1347654&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/binary_constant.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/binary_constant.q Thu Jun 7 14:55:49 2012
@@ -0,0 +1 @@
+select cast(cast('a' as binary) as string) from src limit 1;
Added: hive/trunk/ql/src/test/results/clientpositive/binary_constant.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/binary_constant.q.out?rev=1347654&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/binary_constant.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/binary_constant.q.out Thu Jun 7 14:55:49 2012
@@ -0,0 +1,9 @@
+PREHOOK: query: select cast(cast('a' as binary) as string) from src limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(cast('a' as binary) as string) from src limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+a
Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java?rev=1347654&r1=1347653&r2=1347654&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorFactory.java Thu Jun 7 14:55:49 2012
@@ -20,20 +20,21 @@ package org.apache.hadoop.hive.serde2.ob
import java.util.HashMap;
+import org.apache.hadoop.hive.serde2.io.ByteWritable;
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritable;
import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
-import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.BooleanWritable;
-import org.apache.hadoop.hive.serde2.io.ByteWritable;
-import org.apache.hadoop.hive.serde2.io.ShortWritable;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.FloatWritable;
-import org.apache.hadoop.hive.serde2.io.DoubleWritable;
-import org.apache.hadoop.hive.serde2.io.TimestampWritable;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
/**
* PrimitiveObjectInspectorFactory is the primary way to create new
@@ -190,6 +191,8 @@ public final class PrimitiveObjectInspec
return new WritableConstantStringObjectInspector((Text)value);
case TIMESTAMP:
return new WritableConstantTimestampObjectInspector((TimestampWritable)value);
+ case BINARY:
+ return new WritableConstantBinaryObjectInspector((BytesWritable)value);
case VOID:
return new WritableVoidObjectInspector();
default:
Added: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java?rev=1347654&view=auto
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java (added)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableConstantBinaryObjectInspector.java Thu Jun 7 14:55:49 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.serde2.objectinspector.primitive;
+
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+import org.apache.hadoop.io.BytesWritable;
+
+/**
+ * A WritableConstantBinaryObjectInspector is a WritableBinaryObjectInspector
+ * that implements ConstantObjectInspector.
+ */
+public class WritableConstantBinaryObjectInspector extends
+ WritableBinaryObjectInspector implements
+ ConstantObjectInspector {
+
+ private final BytesWritable value;
+
+ public WritableConstantBinaryObjectInspector(BytesWritable value) {
+ super();
+ this.value = value;
+ }
+
+ @Override
+ public BytesWritable getWritableConstantValue() {
+ return value;
+ }
+
+}