Author: namit
Date: Thu Nov 3 05:12:38 2011
New Revision: 1196944
URL: http://svn.apache.org/viewvc?rev=1196944&view=rev
Log:
HIVE-1310 Partitioning columns should be of primitive types only
(Ashutosh Chauhan via namit)
Added:
hive/trunk/ql/src/test/queries/clientnegative/part_col_complex_type.q
hive/trunk/ql/src/test/results/clientnegative/part_col_complex_type.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java?rev=1196944&r1=1196943&r2=1196944&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
(original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java Thu
Nov 3 05:12:38 2011
@@ -189,6 +189,7 @@ public enum ErrorMsg {
+ "If you really want to perform the operation, set
hive.mapred.mode=nonstrict"),
PARTSPEC_DIFFER_FROM_SCHEMA("Partition columns in partition specification
are not the same as "
+ "that defined in the table schema. The names and orders have to be
exactly the same."),
+ PARTITION_COLUMN_NON_PRIMITIVE("Partition column must be of primitive
type."),
;
private String mesg;
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1196944&r1=1196943&r2=1196944&view=diff
==============================================================================
---
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
(original)
+++
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
Thu Nov 3 05:12:38 2011
@@ -162,6 +162,8 @@ import org.apache.hadoop.hive.serde2.obj
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
import org.apache.hadoop.hive.serde2.objectinspector.StructField;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
+import
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
@@ -8022,7 +8024,14 @@ public class SemanticAnalyzer extends Ba
// there is no overlap between columns and partitioning columns
Iterator<FieldSchema> partColsIter = crtTblDesc.getPartCols().iterator();
while (partColsIter.hasNext()) {
- String partCol = partColsIter.next().getName();
+ FieldSchema fs = partColsIter.next();
+ String partCol = fs.getName();
+ PrimitiveTypeEntry pte =
PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(
+ fs.getType());
+ if(null == pte){
+ throw new
SemanticException(ErrorMsg.PARTITION_COLUMN_NON_PRIMITIVE.getMsg() + " Found "
+ + partCol + " of type: " + fs.getType());
+ }
Iterator<String> colNamesIter = colNames.iterator();
while (colNamesIter.hasNext()) {
String colName = unescapeIdentifier(colNamesIter.next());
Added: hive/trunk/ql/src/test/queries/clientnegative/part_col_complex_type.q
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/part_col_complex_type.q?rev=1196944&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/part_col_complex_type.q
(added)
+++ hive/trunk/ql/src/test/queries/clientnegative/part_col_complex_type.q Thu
Nov 3 05:12:38 2011
@@ -0,0 +1 @@
+create table t (a string) partitioned by (b map<string,string>);
Added: hive/trunk/ql/src/test/results/clientnegative/part_col_complex_type.q.out
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/part_col_complex_type.q.out?rev=1196944&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/part_col_complex_type.q.out
(added)
+++ hive/trunk/ql/src/test/results/clientnegative/part_col_complex_type.q.out
Thu Nov 3 05:12:38 2011
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: Partition column must be of primitive
type. Found b of type: map<string,string>