hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1382211 [1/3] - in /hive/trunk: ql/src/test/queries/clientpositive/ ql/src/test/results/clientpositive/ serde/if/test/ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/ serde/src/java/org/apache/hadoop/hive/serde...
Date Fri, 07 Sep 2012 23:50:38 GMT
Author: hashutosh
Date: Fri Sep  7 23:50:38 2012
New Revision: 1382211

URL: http://svn.apache.org/viewvc?rev=1382211&view=rev
Log:
HIVE-3323 : enum to string conversions (Travis Crawford via Ashutosh Chauhan)

Added:
    hive/trunk/ql/src/test/queries/clientpositive/convert_enum_to_string.q
    hive/trunk/ql/src/test/results/clientpositive/convert_enum_to_string.q.out
    hive/trunk/serde/if/test/megastruct.thrift
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MiniStruct.java
    hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MyEnum.java
Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorFactory.java
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/JavaStringObjectInspector.java

Added: hive/trunk/ql/src/test/queries/clientpositive/convert_enum_to_string.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/convert_enum_to_string.q?rev=1382211&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/convert_enum_to_string.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/convert_enum_to_string.q Fri Sep  7 23:50:38
2012
@@ -0,0 +1,10 @@
+-- Ensure Enum fields are converted to strings (instead of struct<value:int>)
+
+create table convert_enum_to_string
+  partitioned by (b string)
+  row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer"
+    with serdeproperties (
+      "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct",
+      "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol");
+
+describe convert_enum_to_string;

Added: hive/trunk/ql/src/test/results/clientpositive/convert_enum_to_string.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/convert_enum_to_string.q.out?rev=1382211&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/convert_enum_to_string.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/convert_enum_to_string.q.out Fri Sep  7
23:50:38 2012
@@ -0,0 +1,44 @@
+PREHOOK: query: -- Ensure Enum fields are converted to strings (instead of struct<value:int>)
+
+create table convert_enum_to_string
+  partitioned by (b string)
+  row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer"
+    with serdeproperties (
+      "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct",
+      "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol")
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: -- Ensure Enum fields are converted to strings (instead of struct<value:int>)
+
+create table convert_enum_to_string
+  partitioned by (b string)
+  row format serde "org.apache.hadoop.hive.serde2.thrift.ThriftDeserializer"
+    with serdeproperties (
+      "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.MegaStruct",
+      "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol")
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@convert_enum_to_string
+PREHOOK: query: describe convert_enum_to_string
+PREHOOK: type: DESCTABLE
+POSTHOOK: query: describe convert_enum_to_string
+POSTHOOK: type: DESCTABLE
+my_bool	boolean	from deserializer
+my_byte	tinyint	from deserializer
+my_16bit_int	smallint	from deserializer
+my_32bit_int	int	from deserializer
+my_64bit_int	bigint	from deserializer
+my_double	double	from deserializer
+my_string	string	from deserializer
+my_binary	struct<hb:binary,offset:int,isreadonly:boolean,bigendian:boolean,nativebyteorder:boolean>
from deserializer
+my_string_string_map	map<string,string>	from deserializer
+my_string_enum_map	map<string,string>	from deserializer
+my_enum_string_map	map<string,string>	from deserializer
+my_enum_struct_map	map<string,struct<my_string:string,my_enum:string>>	from deserializer
+my_enum_stringlist_map	map<string,array<string>>	from deserializer
+my_enum_structlist_map	map<string,array<struct<my_string:string,my_enum:string>>>
from deserializer
+my_stringlist	array<string>	from deserializer
+my_structlist	array<struct<my_string:string,my_enum:string>>	from deserializer
+my_enumlist	array<string>	from deserializer
+my_stringset	struct<>	from deserializer
+my_enumset	struct<>	from deserializer
+my_structset	struct<>	from deserializer
+b	string	

Added: hive/trunk/serde/if/test/megastruct.thrift
URL: http://svn.apache.org/viewvc/hive/trunk/serde/if/test/megastruct.thrift?rev=1382211&view=auto
==============================================================================
--- hive/trunk/serde/if/test/megastruct.thrift (added)
+++ hive/trunk/serde/if/test/megastruct.thrift Fri Sep  7 23:50:38 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+
+/**
+ * MetaStruct intends to stress test Hive's thrift support by having all
+ * sorts of crazy but valid field types. Please add new fields if you find
+ * a case that's not handled correctly.
+ */
+
+namespace java org.apache.hadoop.hive.serde2.thrift.test
+
+enum MyEnum {
+  LLAMA = 1,
+  ALPACA = 2
+}
+
+struct MiniStruct {
+  1: optional string my_string,
+  2: optional MyEnum my_enum
+}
+
+struct MegaStruct {
+   1: optional bool my_bool,
+   2: optional byte my_byte,
+   3: optional i16 my_16bit_int,
+   4: optional i32 my_32bit_int,
+   5: optional i64 my_64bit_int,
+   6: optional double my_double,
+   7: optional string my_string,
+   8: optional binary my_binary,
+   9: optional map<string, string> my_string_string_map,
+  10: optional map<string, MyEnum> my_string_enum_map,
+  11: optional map<MyEnum, string> my_enum_string_map,
+  12: optional map<MyEnum, MiniStruct> my_enum_struct_map,
+  13: optional map<MyEnum, list<string>> my_enum_stringlist_map,
+  14: optional map<MyEnum, list<MiniStruct>> my_enum_structlist_map,
+  15: optional list<string> my_stringlist,
+  16: optional list<MiniStruct> my_structlist,
+  17: optional list<MyEnum> my_enumlist,
+  18: optional set<string> my_stringset,
+  19: optional set<MyEnum> my_enumset,
+  20: optional set<MiniStruct> my_structset
+}



Mime
View raw message